openCamera static method
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;
}
}