Flutter hooks for state management
Flutter hooks are functions that hold state or logic and return a value a widget or another hook can use. In utopia_hooks, the hook model is not limited to local widget state. The same primitive powers local state, shared app state, async loading, pagination, form fields, and unit-testable screen logic.
If you come from React, the entry point is familiar: useState stores a mutable value, useEffect runs lifecycle work, and useMemoized derives values from dependencies. The difference is that Flutter has no virtual DOM and no React context tree; utopia_hooks adds the Flutter-specific pieces needed to make hooks the architecture of a whole app.
What hooks cover
| Problem | utopia_hooks answer | Start here |
|---|---|---|
| Local screen state | useState, composed into a useXScreenState hook | Basics |
| Derived values | useMemoized keyed on explicit dependencies | Common hooks |
| Side effects | useEffect, with optional cleanup | useEffect |
| Shared app state | HookProviderContainerWidget + useProvided<T>() | Global state |
| Async reads | useAutoComputedState | FutureBuilder alternative |
| Writes and submits | useSubmitState | Submit state |
| Infinite scroll | usePaginatedComputedState + PaginatedComputedStateWrapper | Pagination |
| Forms | useFieldState + TextEditingControllerWrapper | Forms and fields |
| Unit tests | SimpleHookContext | Testing |
Hooks as architecture
A hook by itself is just a primitive. The architecture comes from where hooks are allowed to live.
Every non-trivial screen follows Screen / State / View:
screens/profile
|- profile_screen.dart
|- state/profile_screen_state.dart
|- view/profile_screen_view.dart
The Screen is a thin coordinator that reads BuildContext, builds navigation callbacks, calls one state hook, and returns the View. The state hook owns the logic. The View is a StatelessWidget that receives only state.
That split is what lets hooks scale past a counter example. It gives the screen one place for logic, one place for UI, and a state hook that can run under SimpleHookContext without pumping a widget tree.
utopia_hooks and flutter_hooks
flutter_hooks is the established hook primitive for Flutter widgets. utopia_hooks is a separate implementation with a different goal: using hooks as the state-management layer for the whole presentation architecture.
The practical difference:
| If you need... | flutter_hooks | utopia_hooks |
|---|---|---|
| Local widget hooks | Yes | Yes |
| Global app state as hooks | Bring another state solution | Built in with providers + useProvided |
| Unit-test hooks without a widget tree | Widget-test oriented | SimpleHookContext |
| Architecture conventions | Out of scope | Screen / State / View |
| Managed async and pagination hooks | Bring your own patterns | useAutoComputedState, usePaginatedComputedState |
See the full comparison in utopia_hooks vs flutter_hooks.
Best starting paths
- New to hooks: Basics
- Choosing architecture: Flutter architecture with Screen / State / View
- Coming from React: React to Flutter with hooks
- Replacing
StatefulWidget: utopia_hooks vs StatefulWidget - Comparing libraries: Comparisons
- Building with coding agents: AI-friendly Flutter state management