Skip to content

Instantly share code, notes, and snippets.

@themisir
Created February 19, 2020 19:08
Show Gist options
  • Save themisir/0ba874e090585b8275b23b9d6a676277 to your computer and use it in GitHub Desktop.
Save themisir/0ba874e090585b8275b23b9d6a676277 to your computer and use it in GitHub Desktop.
Future<int> add(int a, int b) async {
return Future.delayed(Duration(seconds: 2)).then((f) {
return a + b;
});
}
Future<int> test(Future<int> Function(int a, int b) func) async {
return await func(3, 2);
}
void main() {
test(add)
.then(print); /// will return result of 3+2 after 2 seconds
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment