pickFiles method

Future<FilePickerResult?> pickFiles({
  1. FileType type = FileType.any,
  2. int compressionQuality = 30,
  3. bool allowMultiple = false,
  4. bool withData = false,
  5. bool withReadStream = false,
  6. bool lockParentWindow = false,
  7. List<String>? allowedExtensions,
})

Returns the FilePickerResult of the file picking of the provided type.

Implementation

Future<FilePickerResult?> pickFiles({
  FileType type = FileType.any,
  int compressionQuality = 30,
  bool allowMultiple = false,
  bool withData = false,
  bool withReadStream = false,
  bool lockParentWindow = false,
  List<String>? allowedExtensions,
}) async {
  try {
    FileType accounted = type;
    if (type == FileType.custom && isMobile) {
      if (allowedExtensions == NativeFile.images) {
        accounted = FileType.image;
        allowedExtensions = null;
      }
    }

    return await FilePicker.platform.pickFiles(
      type: accounted,
      compressionQuality: compressionQuality,
      allowMultiple: allowMultiple,
      withData: withData,
      withReadStream: withReadStream,
      lockParentWindow: lockParentWindow,
      allowedExtensions: accounted == FileType.custom
          ? allowedExtensions
          : null,
    );
  } on PlatformException catch (e) {
    if (e.code == 'already_active') {
      return null;
    } else {
      rethrow;
    }
  }
}