Answers for "write and read to file in flutter"

0

write and read to file in flutter

Future<File> get _localFile async {
  final path = await _localPath;
  return File('$path/counter.txt');
}
Posted by: Guest on January-10-2021
0

write and read to file in flutter

Future<int> readCounter() async {
  try {
    final file = await _localFile;

    // Read the file.
    String contents = await file.readAsString();

    return int.parse(contents);
  } catch (e) {
    // If encountering an error, return 0.
    return 0;
  }
}
Posted by: Guest on January-10-2021
0

write and read to file in flutter

Future<File> writeCounter(int counter) async {
  final file = await _localFile;

  // Write the file.
  return file.writeAsString('$counter');
}
Posted by: Guest on January-10-2021
0

write and read to file in flutter

Future<String> get _localPath async {
  final directory = await getApplicationDocumentsDirectory();

  return directory.path;
}
Posted by: Guest on January-10-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language