go_provider
2.0.2, released 3 months ago by branvier.com
Scope Provider or Bloc instances to specific go_router routes.
WASM-ready
What it does
Provides GoProviderRoute and ShellProviderRoute widgets that attach providers to a route hierarchy. Providers are created when the route is entered and disposed when the route is popped, simplifying scoped state management with go_router.
AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need route‑specific state without lifting providers to the app root
- You use go_router and want automatic provider lifecycle tied to navigation
Skip it when
- You prefer a global provider architecture
- You need code‑generation‑based state management
Strengths
- Easy integration with existing Provider or Bloc code
- Automatic disposal of scoped providers
- Works with custom pages via copyWith
Weaknesses
- Adds an extra Navigator which can affect canPop behavior
- Limited to Provider/Bloc patterns, no built‑in support for Riverpod
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
GoProviderRoute(
path: '/home',
providers: (c, s) => [ChangeNotifierProvider(create: (_) => UserState())],
builder: (c, s) => const HomePage(),
);Alternatives
Packages that do the same job and could replace go_provider.
- provider
Standard way to scope providers manually in the widget tree
81Compare - flutter_bloc
Provides similar scoped Bloc support without extra routing wrapper
86Compare
Works with
Packages commonly used together with go_provider: ones it builds on, ones built on it, and its own family.
- go_routergo_provider depends on itDeclarative routing package for Flutter based on Navigation 2 supporting deep links and URL-based navigation.
- nestedgo_provider depends on itWidget that flattens deeply nested widget trees into a list of children.
- go_transitionsSame familyCreate, combine and apply custom page transitions to routes with GoRouter and Navigator.