Created
November 15, 2019 00:24
-
-
Save ditman/f062d40311b09b39c6bdef925137653e to your computer and use it in GitHub Desktop.
await (Function) fn(); for non async fns
This file contains 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<String> asyncFunctionn() async { | |
return Future<String>.delayed( | |
const Duration(milliseconds: 10), | |
() => "Async function", | |
); | |
} | |
String syncFunction() { | |
return "Sync function"; | |
} | |
void run(Function fn) async { | |
print(await fn()); | |
} | |
void main() async { | |
await run(asyncFunctionn); | |
run(syncFunction); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment