Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Well ... no. Await is non-blocking. Your example is misleading once again :-)
- // Example A:
- ranBool(5).then((ret) => print(ret.toString()));
- new Timer(const Duration(seconds: 2), () {
- print('timer finished');
- });
- // is NOT the same as Example B:
- if (await ranBool(5))
- print('true');
- else
- print('false');
- new Timer(const Duration(seconds: 2), () {
- print('timer finished');
- });
- // Without the await magic, Example B would look like this (Example C):
- ranBool(5).then((ret) {
- print(ret.toString()));
- new Timer(const Duration(seconds: 2), () {
- print('timer finished');
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement