file.readAsString() as string to json in flutter code example
Example 1: write and read to file in flutter
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Example 2: write and read to file in flutter
Future<File> writeCounter(int counter) async {
final file = await _localFile;
// Write the file.
return file.writeAsString('$counter');
}