Eternalcode Eternalcode - 2 months ago 9x
Dart Question

Can anyone explain this behavior?

I accidentally came across this behavior while playing around the async behavior.

Can anyone explain to me why the setTimeout with 0 seconds is not executing the print statement immediately?


setTimeout enqueues the passed function into the event queue and the passed code is executed async.

The sync code is executed to the end and then the next event in the event queue is processed.