Blog

[Flutter] How future and await code runs

Published 1 min read

How a Future proceeds

  1. The future object is registered in an internal array.

  2. The code related to the future is registered in the event queue.

  3. An empty future object is returned.

  4. All the code that has to run synchronously runs

  5. Once everything has run, the remaining actual data is delivered to the future

Async method : always returns a future (main method seems to be the exception)

  1. Code runs synchronously until it hits await
  2. When it hits await, it returns an empty future type and waits until the function in await finishes
  3. When that finishes, the next code runs

Comments

Leaving a comment stores your nickname (or GitHub profile info). Privacy policy

GitHub