Created
August 20, 2022 10:30
-
-
Save mym0404/cb51502b60ae9e1dad33603ff0a028dc 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
import 'dart:async'; | |
main() { | |
print(1); | |
futureNoDelay(2).then(print); | |
future(3).then(print); | |
futureSync(4).then(print); | |
futureSyncReturnFuture(5).then(print); | |
futureSyncReturnFutureValue(6).then(print); | |
futureValue(7).then(print); | |
scheduleMicrotask(() => print(8)); | |
print(9); | |
} | |
Future<int> futureNoDelay(int value) => | |
Future.delayed(Duration.zero, () => value); | |
Future<int> future(int value) => Future(() => value); | |
Future<int> futureSync(int value) => Future.sync(() => value); | |
Future<int> futureSyncReturnFuture(int value) => | |
Future.sync(() => Future(() => value)); | |
Future<int> futureSyncReturnFutureValue(int value) => | |
Future.sync(() => Future.value(value)); | |
Future<int> futureValue(int value) => Future.value(value); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment