Closed deathblade666 closed 1 month ago
I am also getting same issue in Android 14. If I send bytes then it works. Error:
String? outputFile = await FilePicker.platform.saveFile(
dialogTitle: 'Please select an output file:',
fileName: '$fileName${Constants.fileType}',
);
Working:
String? outputFile = await FilePicker.platform.saveFile(
dialogTitle: 'Please select an output file:',
fileName: '$fileName${Constants.fileType}',
bytes: stringToUint8List(fileName),
);
Uint8List stringToUint8List(String data) {
// Convert string to bytes (List<int>)
List<int> encoded = utf8.encode(data);
// Convert List<int> to Uint8List
Uint8List uint8List = Uint8List.fromList(encoded);
return uint8List;
}
This issue is stale because it has been open for 7 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
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
andflutter 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 A clear and concise description of what the bug is. If the issue happens to be on Android, please make sure that it also happens with a different device/simulator and/or version.
On android 15 .saveFile() function returns null array. On Android 14 .saveFile() returns a null array if bytes is not provide (see edit at end of post)
Platform
Platform OS version What version did it happen? 15 beta (august 2024 release) How are you picking?
also tried
Details to reproduce the issue Provide all the details to reproduce the issue.
Add the above code snippet, select a file (or "create" one) press the confirm button
Error Log Please, post the full console log of your issue, if applicable.
Screenshots and/or video If applicable, add screenshots or video to help explain your problem.
Flutter Version details Please, post the output of your
flutter doctor -v
, preferably, while running the issued device/simulator.Additional context Add any other context about the problem here.
There similar issue with other functions like the pickFiles() but i can open a separate issue for that if preferred.I'll open another issue for the pickFiles() as while it doesnt work it doesnt behave the same as detailed in this issue.EDIT: upon further testing, it appears that on android 14 this same issue occurs if bytes is not provided, please consider making it clear in the docs that bytes is required for at least android (unable to test IOS). As it stands the only mention in the docs is "For mobile platforms, this function will save file with bytes to return a path." this does not convey that bytes is required.