How to Show Loading and Error States with AsyncValue in Flutter Riverpod
Render loading, data, and error UI from a single AsyncValue in Riverpod 3. Use AsyncNotifier and AsyncValue.guard for mutations, .when() and switch pattern matching for the UI, keep previous data on refresh, and migrate the legacy StateNotifier pattern. Tested on flutter_riverpod 3.x, Flutter 3.44, Dart 3.x.