Hi everyone, I’m working on an application that allows users to select excel files (.xls and .xlsx) from google drive using file_picker.
When opening the google drive application in the emulator the screen is greyed out and it doesn’t let me select any files.
And this is what I get in the console:
D/FilePickerUtils(15769): Allowed file extensions mimes: [application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/comma-separated-values]
D/FilePickerDelegate(15769): Selected type */*
This is the function that loads the file:
Future<bool> cargarEncuestaDesdeExcel(String? id) async {
// Abre el selector de archivos para seleccionar un archivo Excel
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowedExtensions: ['xlsx', 'xls', 'csv'],
);
var uuid = Uuid();
if (result != null) {
PlatformFile file = result.files.first;
print("====archivo seleccionado: ${file.path} ========");
// Carga el archivo Excel utilizando la dependencia 'excel'
var bytes = File(file.path!).readAsBytesSync();
var excel = Excel.decodeBytes(bytes);
. . .
I modified the function to accept any type of file, but after changing the code the app allowed me to select any file (mp4, jpeg, etc) except excel files, these are the only ones I still can’t use.
I have already activated the Google Drive service from the Google Cloud console and add the permissions in android manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNT" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I’m trying this on an Android emulator, and I’m not sure if it’s an issue with the emulator, package configurations, or file handling on Android.
Has anyone had a similar problem?
Additional details:
- Flutter version: 3.27.1
- Dart Version: 3.6.0
- Gradle Version: 8.4
- Operating System: Windows 10
- VScode version: 1.96.2
- Emulator: Pixel 3a API 34
Main Dependencies:
- firebase_core: ^3.8.1
- cloud_firestore: ^5.6.0
- firebase_core_platform_interface: ^5.3.1
- firebase_auth: ^5.3.4
- google_sign_in: any
- google_sign_in_web: any
- file_picker: ^8.1.7
- excel: any
- uuid: any
- native_notify: ^0.0.3
- background_fetch: ^1.3.7
- firebase_messaging: ^15.1.6
- http: any
- awesome_notifications: ^0.6.21
Any guidance or help would be appreciated. Thanks in advance!