-
Notifications
You must be signed in to change notification settings - Fork 840
Description
Before creating an issue, make sure that you are on the latest file_picker version and that there aren't already any similar opened inssues. Also, check if it isn't described on the Wiki, specially on Troubleshooting page.
Also, sometimes a simple flutter clean and flutter build again with latest file_picker version, may end up by fixing cached issues, so I encourage you to first do so.
Describe the bug
This is reopening of the #1553, because bot closed it, but nobody looked into it.
When using the saveFile() method of the file picker, the returned string path is different from the actual picked file location. It will always be inside the Download folder.
Platform
- Android
- iOS
- Web
- Desktop
Platform OS version
14 (API 34)
How are you picking?
final now = DateTime.now();
final timeStamp = '${now.year}-${now.month}-${now.day}';
final fileName = 'export_$timeStamp.csv';
String? filePath = await FilePicker.platform.saveFile(
dialogTitle: 'Select a folder to export data',
fileName: fileName,
initialDirectory: 'Download',
bytes: Uint8List(
0), //https://github.com/miguelpruivo/flutter_file_picker/issues/1523
);
if (filePath == null) return;
debugPrint(filePath);
Details to reproduce the issue
Provide all the details to reproduce the issue.
Flutter Version details
[✓] Flutter (Channel stable, 3.22.2, on NixOS 24.11 (Vicuna) 6.6.45, locale en_US.UTF-8)
• Flutter version 3.22.2 on channel stable at /nix/store/a62pd11p4cywpm0rh0i092s10dx1wm6m-flutter-wrapped-3.22.2-sdk-links
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision nixpkgs000 (), 1970-01-01 00:00:00
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /nix/store/jnh87nqcvdnda2dvw6qj6rcah1mhqpd4-android-sdk-env/share/android-sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /nix/store/jnh87nqcvdnda2dvw6qj6rcah1mhqpd4-android-sdk-env/share/android-sdk
• ANDROID_SDK_ROOT = /nix/store/jnh87nqcvdnda2dvw6qj6rcah1mhqpd4-android-sdk-env/share/android-sdk
• Java binary at: /nix/store/zv325ff26ahbywl59q8cj9vm63sisna6-openjdk-17.0.11+9/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+9-nixos)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 18.1.8
• cmake version 3.29.6
• ninja version 1.12.1
• pkg-config version 0.29.2
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[✓] Connected device (2 available)
• RMX2156L1 (mobile) • AAJJDMCMGEQOEIDE • android-arm64 • Android 14 (API 34)
• Linux (desktop) • linux • linux-x64 • NixOS 24.11 (Vicuna) 6.6.45
[✓] Network resources
• All expected network resources are available.
Additional context
The android implementation of saveFile uses Environment.DIRECTORY_DOWNLOADS, so safeFile will always return the path to the downloads directory.
flutter_file_picker/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerDelegate.java
Lines 91 to 92 in 8bbe066
| String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) | |
| .getAbsolutePath() + File.separator + FileUtils.getFileName(uri, this.activity); |
if nobody knows for now, how to resolve this issue, then as a hack, is it possible to use saveFile method without dialog?