write and read to file in flutter
Future<File> get _localFile async {
final path = await _localPath;
return File('$path/counter.txt');
}
write and read to file in flutter
Future<File> get _localFile async {
final path = await _localPath;
return File('$path/counter.txt');
}
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;
}
}
write and read to file in flutter
Future<File> writeCounter(int counter) async {
final file = await _localFile;
// Write the file.
return file.writeAsString('$counter');
}
write and read to file in flutter
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us