Skip to content
pubscout

go_provider

2.0.2, released 3 months ago by branvier.com

Scope Provider or Bloc instances to specific go_router routes.

WASM-ready
$ flutter pub add go_provider
Source repository

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.

Works with

Packages commonly used together with go_provider: ones it builds on, ones built on it, and its own family.