flutter-package / images_picker

Flutter plugin for selecting images/videos from the Android and iOS gallery, and taking pictures/videos with the camera
MIT License
66 stars 84 forks source link
album android camera compress crop flutter flutter-plugin gallery imagepick images-picker ios photo picker pictures video wechat

images_picker

images-picker

Flutter plugin for selecting images/videos from the Android and iOS image library, and taking pictures/videos with the camera,save image/video to album/gallery

ios(10+): ZLPhotoBrowser

android(21+): PictureSelector

Support

Install

For ios:

<key>NSCameraUsageDescription</key>
<string>Example usage description</string>
<key>NSMicrophoneUsageDescription</key>
<string>Example usage description</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Example usage description</string>

For android:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Goto android/app/build.gradle
minSdkVersion 21

And,

images_picker: ^newest
import "package:images_picker/images_picker.dart";

Usage

Future getImage() async {
    List<Media> res = await ImagesPicker.pick(
      count: 3,
      pickType: PickType.image,
    );
// Media
// .path
// .thumbPath (path for video thumb)
// .size (kb)
}

because the HTTP request is uncontrollable in plugin(such as progress),you must download file ahead of time

void save() async {
    File file = await downloadFile('https://xxx.example.com/xx.png');
    bool res = await ImagesPicker.saveImageToAlbum(file, albumName: "");
    print(res);
}

Future<File> downloadFile(String url) async {
  Dio simple = Dio();
  String savePath = Directory.systemTemp.path + '/' + url.split('/').last;
  await simple.download(url, savePath,
      options: Options(responseType: ResponseType.bytes));
  print(savePath);
  File file = new File(savePath);
  return file;
}

All params

// for pick
int count = 1,
PickType pickType = PickType.image,
bool gif = true,
int maxTime = 120,
CropOption cropOpt,
int maxSize,
double quality,

// for camera
PickType pickType = PickType.image,
int maxTime = 15,
CropOption cropOpt,
int maxSize,
double quality,

proguard-rules

-keep class com.luck.picture.lib.** { *; }

-dontwarn com.yalantis.ucrop**
-keep class com.yalantis.ucrop** { *; }
-keep interface com.yalantis.ucrop** { *; }

License

MIT License