Menu

1 / 2

Flutter Riverpod 2.0 Advanced — Notifier, AsyncNotifier, Family, and AutoDispose

DEV Community·kanta13jp1·6 months ago
#JJQX7ldb
#flutter#dart#webdev#indiedev#state
Reading 0:00
15s threshold

Flutter Riverpod 2.0 Advanced — Notifier, AsyncNotifier, Family, and AutoDispose

Riverpod 2.0 introduced Notifier and AsyncNotifier as the modern replacement for StateNotifier . This article covers advanced usage patterns for indie Flutter developers building production-grade apps with Supabase.

Notifier vs AsyncNotifier

Notifier<T> handles synchronous state — use it when state transitions resolve immediately without async operations.

// Synchronous state management @riverpod class CounterNotifier extends _$CounterNotifier { @override int build () = > 0 ;

void increment () = > state ++ ; void reset () = > state = 0 ; }

Enter fullscreen mode

Exit fullscreen mode

AsyncNotifier<T> manages state that depends on asynchronous data sources — ideal for API calls or database access.

// Async state management with Supabase @riverpod class UserProfileNotifier extends _$UserProfileNotifier { @override Future < UserProfile > build () async { final userId = ref .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.