Giter Club home page Giter Club logo

Comments (6)

hygehyge avatar hygehyge commented on August 18, 2024 1

@kinex Thanks for quick release!

from flutter_file_dialog.

kinex avatar kinex commented on August 18, 2024

In your code sample you are making some encoding for the data. The issue is most probably related to your own code. Please reopen with a full code sample and OS version information if you still think the issue is related to this plugin.

from flutter_file_dialog.

hygehyge avatar hygehyge commented on August 18, 2024

I have the same issue on Android 13.
Extra content is added to the end of file.
This happens when

  • choose existing file and overwrite it.
  • new file content is shorter than existing file content.

Flutter:3.0.5
Flutter File Dialog:2.3.0

Here is my code.
As you can see, original file is valid json and there is no encoding.

//backup to cache dir.
final tempDirPath = await getTemporaryDirectory();
final backupFilePath = join(tempDirPath.path, 'backup.json');
await _repository.backup(backupFilePath);

//check backup is valid.
final json = File(backupFilePath).readAsStringSync();
jsonDecode(json); //this doesn't throw FormatException, so backup is valid.

//show dialog and save backup file to where user selected.
final fileDialogParams = SaveFileDialogParams(sourceFilePath: backupFilePath);
final savedFilePath = await FlutterFileDialog.saveFile(params: fileDialogParams); //savedFile become invalid json when above conditions are satisfied,

If you have any ideas, please let me know.

from flutter_file_dialog.

hygehyge avatar hygehyge commented on August 18, 2024

I found this on stackoverflow.
Maybe you have to call output.channel.truncate(0) before you write to output.

from flutter_file_dialog.

hygehyge avatar hygehyge commented on August 18, 2024

I have created PR.
Please review and if acceptable, merge it.
Thanks.

from flutter_file_dialog.

kinex avatar kinex commented on August 18, 2024

@hygehyge Thanks for the fix!

from flutter_file_dialog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.