getImageFromGallery static method
Implementation
static Future<List<Uint8ListWithName>> getImageFromGallery(
{bool allowMultiple = false}) async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.media, allowMultiple: allowMultiple, withData: true);
if (result == null) return [];
if (result.files.length == 1) {
File imageFile = File(result.files.single.path!);
Uint8List? image = await editImage(imageFile);
return image != null
? [Uint8ListWithName(image: image, name: result.files.single.name)]
: [];
}
return Future.wait(result.files.where((file) => file.path != null).map(
(file) async => Uint8ListWithName(
image: await File(file.path!).readAsBytes(), name: file.name)));
}