Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created August 20, 2022 10:30
Show Gist options
  • Save mym0404/cb51502b60ae9e1dad33603ff0a028dc to your computer and use it in GitHub Desktop.
Save mym0404/cb51502b60ae9e1dad33603ff0a028dc to your computer and use it in GitHub Desktop.
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