'How to write data to an existing json file in flutter?

How to add data to an existing json file in assets folder in flutter based on input given by user?



Solution 1:[1]

Create a model as your JSON and add the fromJson toJson method. Call the model class and pass your new data init. Read this documation: https://docs.flutter.dev/development/data-and-backend/json

Solution 2:[2]

You cannot do this. Assets are read-only. Read this for options on how to persist data between app runs: https://docs.flutter.dev/cookbook/persistence

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 monzim
Solution 2 Alexey Inkin