Skip to content

Instantly share code, notes, and snippets.

@bsutton
Created January 31, 2020 05:24
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 bsutton/a42cce3edf01b222206a627e8c8106af to your computer and use it in GitHub Desktop.
Save bsutton/a42cce3edf01b222206a627e8c8106af to your computer and use it in GitHub Desktop.
completers and await
import 'dart:async';
void main() {
print('hi');
var res = doCalc();
print('value = ${res}');
res.then((result) => print('result = $result'));
}
Future<int> doCalc() async
{
var done = Completer<int>();
await Future.delayed(Duration(seconds: 4),
() {
done.complete(10);
});
return done.future;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment