Problem Statement
What does the async keyword do in Dart?
Explanation
The async keyword marks a function as asynchronous, allowing you to use await inside it to pause execution until a Future completes, then resume with the result. Async functions always return a Future, even if you don't explicitly return one - returning a value T automatically wraps it in Future<T>. This makes writing asynchronous code look synchronous and sequential.
Without async/await, you'd need callbacks or then() chains making code harder to read and maintain. Async/await provides clean, readable syntax for async operations that looks like synchronous code. For example, var data = await fetchData() pauses the function until fetchData completes, then assigns the result to data and continues executing.
You can only use await inside async functions - using it elsewhere causes compile errors. The await keyword unwraps Future values, so if fetchData() returns Future<String>, await fetchData() gives you String directly. This eliminates callback hell and makes error handling with try-catch natural for async operations.
