In the Dart documentation The Event Loop and Dart (2013) it mentions that any Future is added to the Event queue.
It also mentions that Microtask queues are meant to always run first, then Event queues.
This documentation is old, and seems geared towards web development so I'm not sure if this is different for Flutter as when I do this code.
Future<String> myFunction() => new Future.value('Hello');
Future<String> myFunction2() => new Future.value('Hello2');
Future<void> mainTest() async {
debugPrint("Sync1");
myFunction().then(debugPrint);
scheduleMicrotask(() { debugPrint("Microtask"); });
myFunction2().then(debugPrint);
debugPrint("Sync2");
}
I get an output of
I/flutter ( 6731): Sync1
I/flutter ( 6731): Sync2
I/flutter ( 6731): Hello
I/flutter ( 6731): Microtask
I/flutter ( 6731): Hello2
But if all Microtasks were meant to be run before the next Event loop, shouldn't it be this?
I/flutter ( 6731): Sync1
I/flutter ( 6731): Sync2
I/flutter ( 6731): Microtask // This running first before the Futures?
I/flutter ( 6731): Hello
I/flutter ( 6731): Hello2