picker static method

Future<List<FileData>?> picker({
  1. FastPickerType type = FastPickerType.image,
  2. List<String>? accept,
  3. bool multiple = false,
  4. bool allotComplession = true,
  5. int compressionQuality = 30,
  6. String? dialogTitle,
  7. String? initialDirectory,
  8. bool lockParentWindow = false,
  9. dynamic onFileLoading(
    1. FilePickerStatus
    )?,
  10. bool readSequential = false,
  11. bool withData = false,
  12. bool withReadStream = false,
})

Implementation

static Future<List<FileData>?> picker({
  FastPickerType type = FastPickerType.image,
  List<String>? accept,
  bool multiple = false,
  bool allotComplession = true,
  int compressionQuality = 30,
  String? dialogTitle,
  String? initialDirectory,
  bool lockParentWindow = false,
  dynamic Function(FilePickerStatus)? onFileLoading,
  bool readSequential = false,
  bool withData = false,
bool withReadStream = false,


}) async {
  try {
    final result = await FilePicker.platform.pickFiles(
      allowMultiple: multiple,
      type: type._picker,
      allowedExtensions: accept,
      allowCompression: allotComplession,
      compressionQuality: compressionQuality,
      dialogTitle: dialogTitle,
      initialDirectory: initialDirectory,
      lockParentWindow:  lockParentWindow,
      onFileLoading: onFileLoading,
      readSequential: readSequential,
      withData: withData,
      withReadStream: withReadStream
    );
    if (result != null) {
      return result.files.map<FileData>((e) {
        final file = File(e.path!);
        return FileData(
          data: file.readAsBytesSync(),
          path: file.path,
        );
      }).toList();
    }
  } on UnimplementedError {
    throw 'Unimplemented method channel -> please, uninstall your app and install again.';
  } catch (e) {
    rethrow;
  }
  return null;
}