Created
August 3, 2019 13:19
-
-
Save zolotyh/33173b1df61c9f66325d526d19451d05 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: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