Skip to content

Instantly share code, notes, and snippets.

@ditman
Created November 15, 2019 00:24
Show Gist options
  • Save ditman/f062d40311b09b39c6bdef925137653e to your computer and use it in GitHub Desktop.
Save ditman/f062d40311b09b39c6bdef925137653e to your computer and use it in GitHub Desktop.
await (Function) fn(); for non async fns
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