Writing
Mobile English

Riverpod 3 Without Codegen: State Management That Fits in Your Head

Reactive Flutter state with plain providers - no build_runner, no generated files, no waiting. The patterns I use in production.

  • Published
  • 1 min read

build_runner is a tax: every model tweak costs a generate cycle, and generated files pollute every code review. Riverpod 3 works beautifully without any of it - if you keep the provider graph disciplined.

Three provider shapes cover 90% of an app

dart
// 1. Immutable dependency
final apiProvider = Provider((ref) => ItemsApi(baseUrl: env.apiUrl));

// 2. Async data with caching + invalidation
final itemsProvider = FutureProvider.autoDispose((ref) async {
  return ref.watch(apiProvider).fetchItems();
});

// 3. Mutable screen state
final filterProvider = NotifierProvider<FilterNotifier, Filter>(FilterNotifier.new);

Rules that keep it maintainable

  • Providers depend on providers, widgets depend on providers, never the reverse. The graph flows one way.
  • autoDispose by default. Long-lived caches are the exception you justify, not the default you forget.
  • One Notifier per screen concern. A 400-line notifier is three notifiers wearing a coat.

Combined with Clean Architecture layers (domain knows nothing about Riverpod), the result is state management you can explain to the next developer on the project in one whiteboard session - which is the actual benchmark that matters.