pickImage static method

Future<List<FileData>> pickImage({
  1. UImageSource source = UImageSource.gallery,
  2. bool selfie = false,
  3. bool allowMultiple = false,
  4. int? maxCount,
  5. int? imageQuality,
  6. UCropOptions? crop,
  7. UCameraOptions? cameraOptions,
  8. dynamic action(
    1. List<FileData>
    )?,
})

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>[];
  }
}