pickMultipleImage static method
Picks multiple images
Returns a list of file paths of the selected images.
Calls onError
in case of an error.
Implementation
static Future<List<String>> pickMultipleImage(
BuildContext context, {
required int maxImageCount,
int? minImageCount,
List<String>? selectedImages,
required void Function(String e) onError,
}) async {
try {
final picker = hl_image_picker.HLImagePicker();
final pickedFiles = await picker.openPicker(
selectedIds: selectedImages,
pickerOptions: hl_image_picker.HLPickerOptions(
maxSelectedAssets: maxImageCount,
minSelectedAssets: minImageCount,
mediaType: hl_image_picker.MediaType.image,
),
cropping: false);
if (pickedFiles.isEmpty) return [];
final pathList = pickedFiles.map((e) => e.path).toList();
return pathList;
} catch (e) {
onError(e.toString());
return [];
}
}