pick static method

Future<List<Media>?> pick({
  1. int count = 1,
  2. PickType pickType = PickType.image,
  3. bool gif = true,
  4. int maxTime = 120,
  5. CropOption? cropOpt,
  6. int? maxSize,
  7. double? quality,
  8. Language language = Language.English,
})

Implementation

static Future<List<Media>?> pick({
  int count = 1,
  PickType pickType = PickType.image,
  bool gif = true,
  int maxTime = 120,
  CropOption? cropOpt,
  int? maxSize,
  double? quality,
  Language language = Language.English,
}) async {
  assert(count > 0, 'count must > 0');
  if (quality != null) {
    assert(quality > 0, 'quality must > 0');
    assert(quality <= 1, 'quality must <= 1');
  }
  if (maxSize != null) {
    assert(maxSize > 0, 'maxSize must > 0');
  }
//     try {
    List<dynamic>? res = await _channel.invokeMethod('pick', {
      "count": count,
      "pickType": pickType.toString(),
      "gif": gif,
      "maxTime": maxTime,
      "maxSize": maxSize ?? null,
      "quality": quality ?? -1,
      "cropOption": cropOpt != null
          ? {
              "quality": quality ?? 1,
              "cropType": cropOpt.cropType.toString(),
              "aspectRatioX": cropOpt.aspectRatio?.aspectRatioX,
              "aspectRatioY": cropOpt.aspectRatio?.aspectRatioY,
            }
          : null,
      "language": language.toString(),
    });
    if (res != null) {
      List<Media> output = res.map((image) {
        Media media = Media(
          path: image["path"],
          size: ((image["size"] ?? 0) / 1024).toDouble(),
          thumbPath: image["thumbPath"],
        );
        return media;
      }).toList();
      return output;
    }
    return null;
//     } catch (e) {
//       return null;
//     }
}