Dart Foundations
Async programming
Network calls, file access and database work should not block the UI thread. Dart Futures represent eventual results.
dart
Future<List<String>> loadItems() async {
final response = await api.fetchItems();
return response;
}
try {
final items = await loadItems();
} catch (error) {
// Show a useful error state.
}UI principle
Never make a screen wait silently. Pair asynchronous work with loading, success, empty and error states.
Lesson complete?Use the next lesson to continue the learning path.