Created
June 4, 2018 01:19
-
-
Save ThinkDigitalSoftware/7976bdcf32716cf49d061037756a23d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:io'; | |
main(List<String> arguments) async{ | |
for (var i = 0; i < 10; i++) { | |
write(i.toString()); | |
} | |
var fileContents = await readFile(); | |
print(fileContents); | |
} | |
Future<String> get _localPath async { | |
final directory = new Directory("./"); | |
return directory.path; | |
} | |
Future<File> get _localFile async { | |
final path = await _localPath; | |
return new File("$path/data"); | |
} | |
Future<File> write(String contents) async { | |
final file = await _localFile; | |
return file.writeAsString("$contents\n", mode: FileMode.append); | |
} | |
Future<String> readFile() async { | |
final file = await _localFile; | |
try { | |
String result = await file.readAsString(); | |
return result; | |
} catch (e) { | |
return "no results"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment