Last active
November 21, 2018 11:59
-
-
Save graphicbeacon/2f4656ae3528fbdefd180d50471f4490 to your computer and use it in GitHub Desktop.
Learn Dart #5: Read and write files in under 30 seconds
This file contains 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:io'; | |
main() async { | |
var file = File('data.txt'); | |
var contents; | |
if (await file.exists()) { | |
// Read file | |
contents = await file.readAsString(); | |
print(contents); | |
// Write file | |
var fileCopy = await File('data-copy.txt').writeAsString(contents); | |
print(await fileCopy.exists()); | |
print(await fileCopy.length()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full article and video here: https://dev.to/graphicbeacon/learn-dart-5-read-and-write-files-in-under-30-seconds-2bii