Instantly share code, notes, and snippets.

Embed
What would you like to do?
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