Skip to content

Instantly share code, notes, and snippets.

@mplacona
Created May 3, 2014 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mplacona/a7fa2033a56e14471ebf to your computer and use it in GitHub Desktop.
Save mplacona/a7fa2033a56e14471ebf to your computer and use it in GitHub Desktop.
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