Created
February 19, 2020 19:08
-
-
Save themisir/0ba874e090585b8275b23b9d6a676277 to your computer and use it in GitHub Desktop.
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
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