Skip to content

Instantly share code, notes, and snippets.

@zolotyh
Created August 3, 2019 13:19
Show Gist options
  • Save zolotyh/33173b1df61c9f66325d526d19451d05 to your computer and use it in GitHub Desktop.
Save zolotyh/33173b1df61c9f66325d526d19451d05 to your computer and use it in GitHub Desktop.
import 'dart:async';
import 'dart:io';
void main() async {
try {
await Directory('temp').create();
await File('temp/temp').create();
} catch(e){
}
}
Future<String> completerDemo(){
var completer = new Completer<String>();
Timer(Duration(milliseconds: 300), (){
completer.complete('test');
});
completer.future;
}
void testFutureOr(){
doStuff((i) => '12312');
doStuff((i) async {
return await 'terer';
});
}
typedef FutureOr<String> myTypeDef(int a);
void doStuff(myTypeDef d) async{
await d(12);
}
Future oldApproach(){
return Directory('temp').create().then((d){
return File('temp/teps').create();
}).catchError((e){
print("error is $e");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment