No Description
lucky1213 399b176e8b upgrade 0.5.4 3 years ago
.github Update issue templates 4 years ago
.vscode add pick type params 5 years ago
example upgrade image_picker & fix permission 3 years ago
lib fix video ui 3 years ago
test remove test ref 5 years ago
.gitignore Update ignore. 4 years ago
CHANGELOG.md Update changelog. 4 years ago
LICENSE Update LICENSE 5 years ago
README.md fix pickCamera parameter default & update readme 4 years ago
pubspec.lock upgrade image_picker & fix permission 3 years ago
pubspec.yaml upgrade 0.5.4 3 years ago

README.md

photo

image picker, multi picker

support ios icloud

support video

support camera

use flutter as ui

if you want to build custom ui, you just need api to make custom ui. to use photo_manager or fork the library to custom ui.

install

dependencies:
  photo: 
    git: 
      url: https://git.links123.net/lucky1213/mutli_image_picker.git

Import

import 'package:photo/photo.dart';
import 'package:photo_manager/photo_manager.dart';

Usage 从相册选择

简单示例

void pickAssets() async {
  PickedEntity result = await PhotoPicker.pickAsset(
    context: context, 
    provider: locale,
    type: PickType.onlyImage,
  );
  /// Use assetList to do something.
}

更多的参数

The context is required, other params is optional.

void pickAsset() async {
  PickedEntity result = await PhotoPicker.pickAsset(
    // BuildContext requied
    context: context,
    // item row count
    rowCount: 4,
    // item radio
    itemRadio: 1,
    // max picker image count
    maxSelected: 8,
    // item padding
    padding: 1,
    // i18n provider ,default is chinese. , you can custom I18nProvider or use ENProvider()
    provider: I18nProvider.chinese,
    // preview thumb size , default is 128
    thumbSize: 150,
    // theme, 默认使用MaterialApp定义的theme
    theme: PhotoTheme(),
    // default is common ,or you make custom delegate to sort your gallery
    sortDelegate: SortDelegate.common,
    // if you want to build custom loading widget,extends LoadingDelegate [see example/lib/main.dart]
    loadingDelegate: DefaultLoadingDelegate(), 
    // all/image/video
    pickType: type, 
    // 可以理解为相册文件夹 when [photoPathList] is not null , [pickType] invalid .
    List<AssetPathEntity> photoPathList, 
    //  已选择的asset
    List<AssetEntity> pickedAssetList 
  );

Usage 使用相机

void pickCamera() async {
  // 参数来源自 ImagePicker.pickImage
  File result = await PhotoPicker.pickCamera(
    maxWidth: 100, 
    maxHeight: 100,
    imageQuality: 100,
    preferredCameraDevice: CameraDevice.rear,
  );
}

关于PickedEntity

// 选中的assets 取消/默认 是空数组
List<AssetEntity> asset

// 是否是原图 默认 false
bool isFullImage

About photoPathList params

You can use [photo_manager] package to get List<AssetPathEntity> and handle or cache.

This parameter is then passed into the pickAsset method, where the incoming photoList is rendered instead of the data in the album.

About android

Migrate to androidX

See the gitbook

Glide

Android native use glide to create image thumb bytes, version is 4.8.0.

If your other android library use the library, and version is not same, then you need edit your android project’s build.gradle.

rootProject.allprojects {

    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.github.bumptech.glide'
                        && details.requested.name.contains('glide')) {
                    details.useVersion "4.8.0"
                }
            }
        }
    }

}

if you use the proguard

see the github

About ios

Because the album is a privacy privilege, you need user permission to access it. You must to modify the Info.plist file in Runner project.

like next

<key>NSPhotoLibraryUsageDescription</key>
<string>App need your agree, can visit your album</string>

Build error

if you build error like include of non-modular header inside framework module, see #10 or so