Created
May 3, 2014 21:58
-
-
Save mplacona/a7fa2033a56e14471ebf to your computer and use it in GitHub Desktop.
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'; | |
import 'dart:async'; | |
Future createFile(String fileName, String text){ | |
return new File(fileName).create() | |
.then((File file){ | |
file.writeAsStringSync(text); | |
return 'the file has been created with "$text" as its content'; | |
}); | |
} | |
void main(){ | |
final String text = "Dart is fun!"; | |
createFile('test.txt', text) | |
.then((value) => print(value)) | |
.catchError((e) => print(e.toString())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment