Ref 03

Riverpod Mental Model & State Graph

Calculating reading time... Module 1.5: Master Reference

🧠 The Riverpod Mental Model

Understand Riverpod as a compile-time safe, unidirectional state tree and dependency graph completely decoupled from Flutter's widget tree.

1. Unidirectional Execution Flow

Action Trigger Flow (User Gesture → API)

UI Widget
ref.read(Notifier)
Repository
Dio ApiClient
Backend API

State Rebuild Flow (API Response → UI Update)

Backend API
DTO Model
state = AsyncValue
ref.watch() Listener
UI Rebuild

2. Dependency Graph vs Provider Graph

Unlike legacy Provider where providers are scoped strictly to widget locations in the BuildContext tree, Riverpod maintains its own independent ProviderGraph inside ProviderContainer:

🌊 Key Takeaway

The Flutter Widget Tree renders visual elements. The Riverpod Provider Graph manages business logic and caching. They run in parallel, connected seamlessly by WidgetRef.