incrediblezayed / file_saver

A simple flutter plugin for saving files in all platforms
https://pub.dev/packages/file_saver
BSD 3-Clause "New" or "Revised" License
75 stars 92 forks source link

android file export error #76

Open lopallo opened 10 months ago

lopallo commented 10 months ago

Hello, on Android with version 0.1.1 I had no problem to export a file, but using version 0.2.8 I get this error: D/FileSaver( 5086): Error While Calling methodNo Activity found to handle Intent { act=android.intent.action.CREATE_DOCUMENT cat=[android.intent.category.OPENABLE] flg=0xc3 (has extras) }

incrediblezayed commented 10 months ago

Hello, on Android with version 0.1.1 I had no problem to export a file, but using version 0.2.8 I get this error: D/FileSaver( 5086): Error While Calling methodNo Activity found to handle Intent { act=android.intent.action.CREATE_DOCUMENT cat=[android.intent.category.OPENABLE] flg=0xc3 (has extras) }

Which android version and can you possibly share a code block?

lopallo commented 10 months ago

I verified with Nexus 5Xapi30 emulator and with smartphone with Android 13

Future exportTurni() async { String esporta = await dbTurni.exportDbTurni(); final directory = await getApplicationDocumentsDirectory(); final path = directory.path; File file = File('$path/turni_mensili.json'); await file.writeAsString(esporta); //controlla se il file è stato effettivamente esportato if (file.existsSync()) { //esporta il file Uint8List bytes = file.readAsBytesSync(); FileSaver.instance.saveAs('turniMensili', bytes, 'json', MimeType.JSON); } else { //mostra un messaggio di errore ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text( 'Errore durante l\'esportazione del file', ), ), ); } } }