InheritedWidgets, but simple
open sourceMITfree
provider is a Flutter state management package: a wrapper around InheritedWidget that makes objects available to the widgets below it and rebuilds them when they change. Providers create values lazily and dispose of them, ChangeNotifierProvider, FutureProvider, StreamProvider and ProxyProvider cover common cases, and widgets read values with context.watch, context.read, Consumer and Selector. Flutter's own state management docs use it with ChangeNotifier, and the app's state is visible in Flutter's DevTools. It's by Remi Rousselet and is a Flutter Favorite on pub.dev.
Problems it solves
- share state between widgets in my Flutter app without passing it through every constructor
- writing InheritedWidget classes by hand in Flutter is too much boilerplate
- rebuild only the Flutter widgets that depend on a value when it changes
- create a service object lazily and dispose of it when it's no longer needed in Flutter
- the simple state management approach the Flutter docs recommend for a beginner app
- inject a repository or API client into my Flutter widget tree
Features
- Provider, ChangeNotifierProvider, FutureProvider, StreamProvider and ProxyProvider
- Lazy creation and automatic disposal of provided objects
- context.watch, context.read, Consumer and Selector to read values
- MultiProvider to combine providers
- State visible in Flutter DevTools
- Android, iOS, Linux, macOS, web and Windows
Alternatives
The same job
These do what provider does.
- June Flutter state management that feels like Flutter
- Bloc Predictable state management for Dart and Flutter with the BLoC pattern
- MobX.dart Reactive state management for Dart and Flutter, a port of MobX
- GetX State management, dependency injection and routing for Flutter in one package
- Flutter Hooks React-style hooks for Flutter widgets
