Explain async , await in Flutter/Dart?
Explain async , await in Flutter/Dart?
Async and await are keywords used in Dart to handle asynchronous code. Here's how they work:
The async keyword is used to mark a function as asynchronous. It allows the function to use await and returns a Future by default.
When you call an async function, it immediately returns a Future object. The function's body continues executing in the background while the Future is returned.
The await keyword is used inside async functions to wait for a Future to complete before continuing execution. It suspends the execution of the async function until the awaited Future completes.
When an await expression is evaluated, the asynchronous function is paused, and the control returns to the caller until the Future completes.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.