Working with Future APIs in Dart
Up until this point, we have been working with synchronous APIs, meaning everything was processed in the same order it was requested, and nothing was processed before the previous event had been handled. However, we have noticed that this approach sometimes blocks the main thread due to greedy operations. Additionally, we observed that all operations were performed on a single thread, the main thread. Moving forward, we will continue to work with this main thread, but we will learn how to prevent thread blocking by utilizing asynchronous APIs.
What does the Future hold?
If you have worked with Flutter, you have likely encountered the concept of Future
. If you are new to this concept, don’t worry – we will cover it from the beginning.
The concept of the Future
class is not unique to Dart. This notion in computer science, also known as promise, delay, or deferred (https://en.wikipedia.org/wiki/Futures_and_promises), describes concepts...