Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saveFile() incomplete documentation #1524

Open
2 of 4 tasks
timoxd7 opened this issue Jun 4, 2024 · 3 comments
Open
2 of 4 tasks

saveFile() incomplete documentation #1524

timoxd7 opened this issue Jun 4, 2024 · 3 comments
Labels
documentation feature-candidate This issue might result in a feature to be implemented

Comments

@timoxd7
Copy link

timoxd7 commented Jun 4, 2024

Describe the bug
On iOS, the saveFile method returns a String. The file then needs to be saved to the path described by this string. The "bytes" parameter has no effect.
On Android however, the Data is given by the "bytes" parameter and this given data is saved instead.

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
iOS 17.5
Android ?

How are you picking?

outputFile = await FilePicker.platform.saveFile(
  dialogTitle: 'Please select an output file:',
  fileName: 'log.txt',
  type: FileType.any,
  bytes: currentLogBytes,
);

if (Platform.isIOS) File(outputFile).write(currentLogBytes);

Details to reproduce the issue
Use Code above.

Flutter Version details
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-arm64, locale de-DE)
• Flutter version 3.22.1 on channel stable at /Users/timo/sdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a14f74ff3a (13 days ago), 2024-05-22 11:08:21 -0500
• Engine revision 55eae6864b
• Dart version 3.4.1
• DevTools version 2.34.3

Additional context
file_picker 8.0.3

@timoxd7 timoxd7 added the new issue An issue that hasn't yet been seen from the maintainer label Jun 4, 2024
@navaronbracke navaronbracke added bug Something isn't working feature-candidate This issue might result in a feature to be implemented and removed new issue An issue that hasn't yet been seen from the maintainer labels Jun 10, 2024
@navaronbracke
Copy link
Collaborator

I think this issue points to a bit of the API that can definitely improve. At the very least, we could do the saving of the file on iOS for you.

@miguelpruivo miguelpruivo added documentation and removed bug Something isn't working labels Aug 25, 2024
@kaciula
Copy link

kaciula commented Sep 18, 2024

This also happens for MacOS and Windows. You need to save the file once you get the output path.

@jahertor
Copy link

jahertor commented Oct 30, 2024

Thanks for your solution, I was going crazy. Could this be a good approach for all platforms?

final file = File(outputFile);
if (!file.existsSync()) {
    file.writeAsBytes(bytes);
}

Because file.isBlank returns false, I don't know why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation feature-candidate This issue might result in a feature to be implemented
Projects
None yet
Development

No branches or pull requests

5 participants