pickMultiFiles method

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

Picks multiple files from the device storage.

Implementation

Future<List<AttachmentResult>> pickMultiFiles({int? maxCount}) async {
  try {
    final List? results = await _channel.invokeMethod('pickMultiFile', {
      '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: pickMultiFile error: $e');
    return [];
  }
}