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

not Work saveAs in windows #119

Open
rezadevelopers2 opened this issue Jun 10, 2024 · 2 comments
Open

not Work saveAs in windows #119

rezadevelopers2 opened this issue Jun 10, 2024 · 2 comments

Comments

@rezadevelopers2
Copy link

rezadevelopers2 commented Jun 10, 2024

`

   await FileSaver.instance.saveAs(
      name: DateTime.now().toString().replaceAll(" ",  "_"),
      ext: ".json",
      mimeType: MimeType.json,
      bytes: Uint8List.fromList(utf8.encode(jsonEncode(jsonStrings))),

    )

`

This code works correctly for Android
But for the Windows and web version, the file is not saved and does not give any error

@YarosMallorca
Copy link

I'm facing this issue, anyone found a solution??

@dasyad00
Copy link

It is mentioned in the README that "you can call saveAs() only available for android and iOS & macOS at the moment". There is a simple workaround, but ideally this would be addressed inside the plugin itself.

final filePath = await FileSaver.instance.saveAs(
  name: fileName,
  bytes: Uint8List(),
  ext: ".$extension",
  mimeType: mimeType,
);
if (filePath == null) {
  // cancelled prompt
  return;
}
// TODO FileSaver.instance.saveAs() as of 0.2.13 on Windows
// only prompts the user for the desired file location, but does not write
// the file passed in.
if (Platform.isWindows) {
  final file = File(filePath);
  await file.writeAsBytes(fileModel.data);
}

If the maintainers need some help with implementing this, I have some time to address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants