Skip to content

Instantly share code, notes, and snippets.

@AlexKenbo
Created March 15, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexKenbo/8eefaaede3454ed64b9e3ab07a5a6cf9 to your computer and use it in GitHub Desktop.
Save AlexKenbo/8eefaaede3454ed64b9e3ab07a5a6cf9 to your computer and use it in GitHub Desktop.
Completer
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