Comments (10)
@cormalenv Yes you have understood it correctly. The API name saveFile
may be slightly confusing, maybe it should be renamed e.g. to exportFile
. So with this api you can export a file from your app to an user selectable location which user can access (which can be e.g. Downloads folder, Googe Drive etc.). The file to export could be an already existing file in your app data like an image file or you could also create a new file to export in a temporary directory (like a backup zip file or exported data in a CSV file).
from flutter_file_dialog.
Thanks @kinex
from flutter_file_dialog.
Did you try it in Android or in iOS? What is the log output when it crashes?
from flutter_file_dialog.
Hi @kinex,
Not sure if this is slightly off topic but I assume SaveFileDialogParams
is essentially "copying" as it requires you to have a file in existence in order to provide an valid file path for the method to re-save it elsewhere. Conceptually then to implement true saving in one's app you would create a _file
in say Directory.systemTemp
and then pass that _file.path
as the sourceFilePath
.
Thanks for the work.
from flutter_file_dialog.
Hello
I was trying it on an Android Emulator through Android Studio.
First, I encode a file in zip format, and then I tried to save it where the user wants to (Google Drive or Downloads for example).
Here is my code :
` try {
debugPrint('Begin to ZIP file');
var encoder = ZipFileEncoder();
encoder.create(donneesVoiture.path);
//Adding files to archive donneesVoiture
encoder.addFile(fileTableVoiture);
encoder.addFile(fileTableEntretien);
encoder.addFile(fileTableHistoriqueEntretiens);
encoder.addFile(fileTableControleTechnique);
encoder.addFile(fileTableModeOPEntretien);
encoder.close();
debugPrint('zip file created');
debugPrint('FlutterSaveDialog : to choose where to store the zip file "donneesVoiture" via a file explorer');
final params = SaveFileDialogParams(sourceFilePath: donneesVoiture.path);
final filePath = await FlutterFileDialog.saveFile(params: params);
debugPrint(filePath);
print(filePath);
} catch (e) {
debugPrint('Error while creating ZIP file');
print(e);
}`
And I got this error :
/FlutterFileDialogPlugin(14505): onMethodCall, method=saveFile D/FileDialog(14505): saveFile - IN, sourceFileName=/storage/emulated/0/Android/data/com.example.carnet_entretien_virtuel/files/DL-749-YE.zip, mimeTypesFilter=null, localOnly=false D/FileDialog(14505): saveFile - OUT E/Surface (14505): getSlotFromBufferLocked: unknown buffer: 0xa1535680 D/EGL_emulation(14505): eglMakeCurrent: 0xab30c220: ver 3 1 (tinfo 0x9f5cb640) E/Surface (14505): getSlotFromBufferLocked: unknown buffer: 0xb40fcd00 D/FlutterView(14505): Detaching from a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@a1df5b2 D/AndroidRuntime(14505): Shutting down VM E/AndroidRuntime(14505): FATAL EXCEPTION: main E/AndroidRuntime(14505): Process: com.example.carnet_entretien_virtuel, PID: 14505 E/AndroidRuntime(14505): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=19112, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/15 flg=0x43 }} to activity {com.example.carnet_entretien_virtuel/com.example.carnet_entretien_virtuel.MainActivity}: kotlin.KotlinNullPointerException E/AndroidRuntime(14505): at android.app.ActivityThread.deliverResults(ActivityThread.java:3699) E/AndroidRuntime(14505): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) E/AndroidRuntime(14505): at android.app.ActivityThread.-wrap16(ActivityThread.java) E/AndroidRuntime(14505): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) E/AndroidRuntime(14505): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(14505): at android.os.Looper.loop(Looper.java:148) E/AndroidRuntime(14505): at android.app.ActivityThread.main(ActivityThread.java:5417) E/AndroidRuntime(14505): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(14505): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) E/AndroidRuntime(14505): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) E/AndroidRuntime(14505): Caused by: kotlin.KotlinNullPointerException E/AndroidRuntime(14505): at com.kineapps.flutter_file_dialog.FileDialog.onActivityResult(FileDialog.kt:134) E/AndroidRuntime(14505): at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:634) E/AndroidRuntime(14505): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:367) E/AndroidRuntime(14505): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:546) E/AndroidRuntime(14505): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:594) E/AndroidRuntime(14505): at android.app.Activity.dispatchActivityResult(Activity.java:6428) E/AndroidRuntime(14505): at android.app.ActivityThread.deliverResults(ActivityThread.java:3695) E/AndroidRuntime(14505): ... 9 more I/Process (14505): Sending signal. PID: 14505 SIG: 9 Lost connection to device.
from flutter_file_dialog.
Same result on a real device
from flutter_file_dialog.
Could you please try this with the provided example app. Clone current master and execute flutter run
in the example directory. Then pick an image file and try to save it to Google Drive. Does this crash also?
Have you already upgraded your Android project to V2 embedding? See https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects . Not sure if the crash could be related to v1 embedding (although it should work also with v1). Example app has been upgraded to v2 embedding.
from flutter_file_dialog.
Similar result as @deacon78, Example code below. v2 embedding in place
FATAL EXCEPTION: main
Process: com..., PID: 5389
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=19112, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/313 flg=0x43 }} to activity {com.../com....MainActivity}: kotlin.KotlinNullPointerException
at android.app.ActivityThread.deliverResults(ActivityThread.java:4339)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4383)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1690)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:171)
at android.app.ActivityThread.main(ActivityThread.java:6627)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: kotlin.KotlinNullPointerException
at com.kineapps.flutter_file_dialog.FileDialog.onActivityResult(FileDialog.kt:134)
at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:634)
at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:367)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:546)
at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:594)
at android.app.Activity.dispatchActivityResult(Activity.java:7343)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4335)
... 9 more
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SafeArea(
child: Scaffold(
body: RaisedButton(
child: Text('Run'),
onPressed: () => run(),
),
),
),
);
}
Future<void> run () async {
File _file = File (Directory.systemTemp.path + "/test.txt");
_file.writeAsStringSync('my string contents');
final params = SaveFileDialogParams(sourceFilePath: _file.path);
final filePath = await FlutterFileDialog.saveFile(params: params);
}
}
EDIT: Removing the following from MainActivity.kt resolved the issue although I am unsure of the broader implications of doing so.
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
By the way the github example does work. Its pulling the plugin into new/existing projects that seems to be the issue. If for instance I create a brand new flutter project in Android Studio with v2 Embedding, latest gradle, API29 etc the issue appears. We don't see this with other plugins.
from flutter_file_dialog.
@cormalenv Thanks for the details. It seems this issue is related to flutter/flutter#48202
from flutter_file_dialog.
Issue fixed in plugin version 0.0.2
from flutter_file_dialog.
Related Issues (20)
- Wrong return path on not choosing folder HOT 1
- Missing file with building for ios
- in ios cant load csv txt xls HOT 1
- build issue in flutter master HOT 1
- Saving file does not overwrite existing unless selected HOT 4
- Extra content being saved to end of file sometimes HOT 6
- Implemented get absolute path for Android using PickiT library HOT 1
- Fatal Exception: java.lang.IllegalStateException Reply already submitted HOT 4
- File dialog now image only? HOT 1
- [bug][invalid_file_extension] Set file extension filter when picking a document.
- Android: Only download or recent available as targets for save HOT 5
- Android: path is incomplete after saveFile HOT 4
- If file already exist then the newly saved file gets renamed after file extension HOT 1
- [Bug]: MissingPluginException (MissingPluginException(No implementation found for method saveFile on channel flutter_file_dialog)) HOT 1
- Support for Windows ?
- Saving file with overwrite makes file unreadable by android OS
- DirectoryLocation custom class HOT 1
- pub.dev release HOT 1
- save multiple File
- No implementation found for method saveFile on channel flutter_file_dialog HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_file_dialog.