openCamera static method

Future<List<Media>?> openCamera({
  1. PickType pickType = PickType.image,
  2. int maxTime = 15,
  3. CropOption? cropOpt,
  4. int? maxSize,
  5. double? quality,
  6. Language language = Language.System,
})

Implementation

static Future<List<Media>?> openCamera({
  PickType pickType = PickType.image,
  int maxTime = 15,
  CropOption? cropOpt,
  int? maxSize,
  double? quality,
  Language language = Language.System,
}) async {
  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('openCamera', {
      "pickType": pickType.toString(),
      "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;
  }
}