pickMultipleImage static method

Future<List<String>> pickMultipleImage(
  1. BuildContext context, {
  2. required int maxImageCount,
  3. int? minImageCount,
  4. List<String>? selectedImages,
  5. required void onError(
    1. String e
    ),
})

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