pickImage static method
Future<List<FileData> >
pickImage({
- UImageSource source = UImageSource.gallery,
- bool selfie = false,
- bool allowMultiple = false,
- int? maxCount,
- int? imageQuality,
- UCropOptions? crop,
- UCameraOptions? cameraOptions,
- dynamic action()?,
Implementation
static Future<List<FileData>> pickImage({
UImageSource source = UImageSource.gallery,
bool selfie = false,
bool allowMultiple = false,
int? maxCount,
int? imageQuality,
UCropOptions? crop,
UCameraOptions? cameraOptions,
Function(List<FileData>)? action,
}) async {
try {
List<FileData> files;
if (source == UImageSource.camera) {
final UCameraOptions base = (cameraOptions ?? const UCameraOptions()).copyWith(
mode: UCameraMode.photo,
allowMultiple: allowMultiple,
maxCount: maxCount ?? 0,
startFront: selfie ? true : null,
);
files = await _applyCrop(await UCamera.open(options: base), crop);
} else {
files = await showFilePicker(fileType: FileType.image, allowMultiple: allowMultiple, crop: crop);
}
action?.call(files);
return files;
} catch (_) {
action?.call(<FileData>[]);
return <FileData>[];
}
}