Not all data in an app is available instantly. API calls, file reads, database queries, and location requests all take time. In Dart, a Future represents a value that will arrive later. async/await is syntax that makes time-consuming code easier to read.
dart
Future<String> fetchUserName() async {
await Future.delayed(const Duration(seconds: 2));
return 'Sai';
}
void main() async {
print('Loading user...');
final name = await fetchUserName();
print('Hello, $name');
}You should see
The console shows "Loading user...", then after 2 seconds, "Hello, Sai" appears.Next Steps
Once you've got the async basics down, learn how to fetch API data using the http package.