Created
March 15, 2020 14:46
-
-
Save AlexKenbo/8eefaaede3454ed64b9e3ab07a5a6cf9 to your computer and use it in GitHub Desktop.
Completer
This file contains hidden or 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'; | |
Future<dynamic> someFutureResult(){ | |
final Completer c = Completer(); | |
// complete will be called in 3 seconds by the timer. | |
new Timer(Duration(seconds: 3), () => c.complete("you should see me second")); | |
return c.future; | |
} | |
main(){ | |
someFutureResult().then((result) => print('$result')); | |
print("you should see me first"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment