#riverpod
Riverpod state management.
- 030Check ref.mounted after an await in a providerA provider can be disposed while a Future is pending. Check ref.mounted after the await before you touch state, or Riverpod 3 throws.
- 027Migrate a StateNotifier to a NotifierStateNotifier now lives in legacy.dart. Moving to Notifier takes a few mechanical steps, and one behaviour change is worth knowing about.
- 025Initialise async dependencies in main() and use requireValueAwait a FutureProvider once before runApp, then read it synchronously everywhere with requireValue. No loading states for things that are always ready.
- 022Pass arguments to a Notifier through its constructorIn Riverpod 3 a family notifier is a plain Notifier that takes its argument in the constructor, so every method can use it as a field.
- 018AsyncValue.guard instead of try/catch in notifiersAsyncValue.guard runs a Future and hands back AsyncData or AsyncError, so notifier methods need no try/catch.
- 014One widget for AsyncValue loading and error statesWrap AsyncValue in a small widget with a switch over AsyncData, AsyncError and AsyncLoading, and every async screen writes only its data UI.
- 012Which Riverpod 3 provider should you use?Six providers cover almost every job in Riverpod 3. StateProvider, StateNotifierProvider and ChangeNotifierProvider now live in legacy.dart.
- 009ref.watch, ref.read or ref.listen?Watch to rebuild, read for a one-off value inside a callback, listen to run side effects like SnackBars.
- 006The parts of a Riverpod 3 providerA provider is a global variable, a type, a body that gets a Ref, and optional modifiers. Here is what each part does.
- 003Getting a Future from a FutureProviderWatch provider.future to await one async provider inside another, and combine the results with plain async code.