# 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](https://github.com/CaiJingLong/flutter_photo_manager) or fork the library to custom ui.

## install

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

## Import

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

## Usage 从相册选择

### 简单示例

```dart
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.

```dart
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 使用相机

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


### 关于`PickedEntity`

```dart
// 选中的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](https://caijinglong.gitbooks.io/migrate-flutter-to-androidx/content/)

### 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.

```groovy
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](https://github.com/bumptech/glide#proguard)

## 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

```plist
<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](https://github.com/CaiJingLong/flutter_photo/issues/10) or [so](https://stackoverflow.com/questions/27776497/include-of-non-modular-header-inside-framework-module)