select static method

Future<List<Media>> select({
  1. PictureMimeType type = PictureMimeType.ofAll,
  2. int max = 1,
  3. int spanCount = 4,
  4. dynamic isCamera = true,
  5. bool enableCrop = false,
  6. bool compress = true,
  7. int ratioX = 1,
  8. int ratioY = 1,
  9. List<String> selectList = list,
})

Implementation

static Future<List<Media>> select(
    {PictureMimeType type = PictureMimeType.ofAll,
    int max = 1,
    int spanCount = 4,
    isCamera = true,
    bool enableCrop = false,
    bool compress = true,
    int ratioX = 1,
    int ratioY = 1,
    List<String> selectList = list}) async {
  int mimeType = 0;
  if (type == PictureMimeType.ofAll) {
    mimeType = 0;
  } else if (type == PictureMimeType.ofImage) {
    mimeType = 1;
  } else if (type == PictureMimeType.ofVideo) {
    mimeType = 2;
  }
  Map<String, dynamic> params = {
    'type': mimeType,
    'max': max,
    'spanCount': spanCount,
    'isCamera': isCamera,
    'enableCrop': enableCrop,
    'compress': compress,
    'ratioX': ratioX,
    'ratioY': ratioY,
    'selectList': selectList,
  };

  List<dynamic> paths = await channel.invokeMethod('select', params);
  List<Media> medias = [];
  for (var data in paths) {
    Media media = Media();
    media.path = data['path'];
    media.cropPath = data['cropPath'];
    media.compressPath = data['compressPath'];
    media.width = data['width'];
    media.height = data['height'];
    medias.add(media);
  }
  return medias;
}