getFileFromDevice static method

Future<List<File>> getFileFromDevice({
  1. bool allowMultiple = false,
})

Implementation

static Future<List<File>> getFileFromDevice(
    {bool allowMultiple = false}) async {
  try {
    FilePickerResult? result = await FilePicker.platform.pickFiles(
        type: FileType.custom,
        withData: true,
        allowMultiple: allowMultiple,
        allowedExtensions: [
          "png",
          "jpg",
          "jpeg",
          "pdf",
          "txt",
          "csv",
          "xlsx"
        ]);
    return (result?.files ?? [])
        .map((PlatformFile file) => File(file.path.toString()))
        .toList();
  } catch (e) {
    return [];
  }
}