async
` keyword, and it typically returns a `Future
` object, which represents the result of the asynchronous operation.Future<String> fetchData() async {
await Future.delayed(Duration(seconds: 2)); // Simulate a network request delay
return 'Data loaded successfully';
}​
fetchData()
` function is marked with the `async
` keyword, and it returns a `Future<String>
` object. The `await
` keyword is used to suspend the function while waiting for the `Future.delayed()
` method to complete. Once the delay is over, the function returns a string that says "Data loaded successfully".FutureBuilder
` and `StreamBuilder
` to update the UI when asynchronous operations complete. For example, you could use the `FutureBuilder
` widget to display a loading indicator while waiting for data to be fetched from a network, and then display the fetched data when it becomes available.