pickImagesUsingImagePicker static method

Future<List<ImageFile>> pickImagesUsingImagePicker(
  1. bool allowMultiple
)

Implementation

static Future<List<ImageFile>> pickImagesUsingImagePicker(
    bool allowMultiple) async {
  final picker = ImagePicker();
  final List<XFile> xFiles;
  if (allowMultiple) {
    xFiles = await picker.pickMultiImage(maxWidth: 1080, imageQuality: 95);
  } else {
    xFiles = [];
    final xFile = await picker.pickImage(
        source: ImageSource.gallery, maxWidth: 1080, imageQuality: 95);
    if (xFile != null) {
      xFiles.add(xFile);
    }
  }
  if (xFiles.isNotEmpty) {
    return xFiles.map<ImageFile>((e) => convertXFileToImageFile(e)).toList();
  }
  return [];
}