pickMultiFromGallery method

Future<List<AttachmentResult>> pickMultiFromGallery({
  1. int? maxCount,
})

Picks multiple images from the device gallery.

Returns a list of AttachmentResult objects.

Implementation

Future<List<AttachmentResult>> pickMultiFromGallery({int? maxCount}) async {
  try {
    final List? results = await _channel.invokeMethod('pickMultiImage', {
      'maxCount': maxCount,
    });
    if (results == null) return [];
    var attachmentResults = results.map((e) => _resultFromPath(e.toString())).toList();

    // Enforce limit in Dart for Android as native might not support it
    if (maxCount != null && maxCount > 0 && attachmentResults.length > maxCount) {
      attachmentResults = attachmentResults.take(maxCount).toList();
    }

    return attachmentResults;
  } catch (e) {
    debugPrint('PixelToPdfService: pickMultiImage error: $e');
    return [];
  }
}