-
-
Save ericgrandt/f30ae96a17de307b8dc0dcb022ba62ed to your computer and use it in GitHub Desktop.
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
// With asynchronous operations | |
import 'dart:async'; | |
main() { | |
longOperation(); | |
printSomething(); | |
} | |
Future<void> longOperation() async { | |
var retVal = await runLongOperation(); | |
print(retVal); | |
} | |
const retString = 'Waited 3 seconds to return this without blocking execution.'; | |
Duration delay = Duration(seconds: 3); | |
Future<String> runLongOperation() => Future.delayed(delay, () => retString); | |
printSomething() { | |
print('I printed right away!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment