Provider — a popular solution for managing Flutter state. We often see Flutter developers spending weeks rewriting state management, starting with Provider and then realizing its limitations. The problem is not Provider but the wrong architecture: chaotic ChangeNotifier, missing repository layer, uncontrolled rebuilds. In this article, we share a proven approach to setting up Provider architecture that we use in commercial projects — from startups to products with 100K+ users. Provider allows implementing state management 2x faster than BLoC due to less boilerplate. According to the official Flutter documentation, Provider is the recommended choice for small and medium applications.
Why Provider Is the Right Choice for a Small Project?
The provider package (currently version 6.x) wraps InheritedWidget into a convenient API and eliminates manual dependency injection. For a team of 1–3 people and an app with 10–20 screens, this is a pragmatic choice: minimal boilerplate, maximum readability. Provider is among the top 3 Flutter packages by downloads — over 3 million per month. It is stable, documented, and maintained by the Flutter team.
Basic Structure with ChangeNotifier
class ProfileNotifier extends ChangeNotifier { final UserRepository _repository; ProfileNotifier(this._repository); UserProfile? _profile; bool _isLoading = false; String? _error; UserProfile? get profile => _profile; bool get isLoading => _isLoading; String? get error => _error; Future<void> load(String userId) async { _isLoading = true; _error = null; notifyListeners(); try { _profile = await _repository.getProfile(userId); } catch (e) { _error = e.toString(); } finally { _isLoading = false; notifyListeners(); } } } Registering in the widget tree:
MultiProvider( providers: [ RepositoryProvider(create: (_) => UserRepositoryImpl()), ChangeNotifierProxyProvider<UserRepositoryImpl, ProfileNotifier>( create: (ctx) => ProfileNotifier(ctx.read()), update: (ctx, repo, prev) => prev!..updateRepo(repo), ), ], child: MyApp(), ) In a widget, use context.watch<ProfileNotifier>() to subscribe to changes or context.read<ProfileNotifier>() to call methods without subscribing.
Optimizing Rebuilds with Selector
The main pitfall of Provider: context.watch() inside build() rebuilds the entire widget on every notifyListeners(). If ProfileNotifier calls notifyListeners() three times during one load — three rebuilds. Solution: Selector<ProfileNotifier, UserProfile?> subscribes only to a specific field, rebuilds only when that field changes.
Selector<ProfileNotifier, bool>( selector: (_, notifier) => notifier.isLoading, builder: (_, isLoading, __) => isLoading ? const CircularProgressIndicator() : const SizedBox(), ) Additionally, split one ChangeNotifier into several by meaning — for example, AuthNotifier, CartNotifier, SettingsNotifier. Use ChangeNotifierProxyProvider to connect them. The Consumer Widget also helps read only necessary data.
How to Set Up MultiProvider for Complex Dependencies?
Note: when the app grows, one ChangeNotifier stops coping. MultiProvider allows registering multiple providers at different levels. It's important to order dependencies correctly: if ProfileNotifier depends on UserRepository, then UserRepository must be above. Use ChangeNotifierProxyProvider to pass dependencies between providers. For a basic flutter provider setup, five steps suffice: define Notifiers, create repositories, configure MultiProvider, connect widgets, and write tests.
Comparison of Provider with Alternatives
| Criterion | Provider 6.x | Riverpod 2.x | BLoC 9.x |
|---|---|---|---|
| Dependency on context | Yes | No | Yes |
| Porting to tests | Medium | Easy | Easy |
| Error handling | Manual | Built-in | Built-in |
| Performance | High | High | Medium |
| Learning curve | Low | Medium | High |
| Async support | ChangeNotifier + Stream | AsyncValue | Stream |
Provider wins in speed of adoption and code readability. If your project does not require complex data flows or detailed testing — stay with Provider. For more flexible testing and reactive data — consider Riverpod. For enterprise apps with hundreds of screens — BLoC.
Typical Use Cases for Provider
| Scenario | Recommended Pattern |
|---|---|
| Simple data reading | Provider or ChangeNotifier |
| Form with fields | Multiple ChangeNotifier or FormBloc |
| Authentication | ChangeNotifier + Stream |
| Request caching | ProxyProvider or RepositoryProvider |
Example of testing a Notifier
void main() { test('ProfileNotifier loads profile', () async { final repo = MockUserRepository(); final notifier = ProfileNotifier(repo); await notifier.load('1'); expect(notifier.isLoading, false); expect(notifier.profile, isNotNull); }); } What Is Included in the Work (Deliverables)
- Design: dependency diagram of Notifiers and Repository, selection of MultiProvider placement.
- Implementation: writing ChangeNotifiers, ProxyProvider, integration with REST/GraphQL, Firebase, or Supabase.
- Tests: unit tests for each Notifier (isolated), widget tests with ProviderScope (for Riverpod) or MultiProvider.
- Documentation: README with architecture diagram and description of data flows.
- Team training: code review session and best practices (30 minutes).
- Support: 2 weeks after delivery — bug fixes, answering questions.
Process of Work
- Requirements analysis (0.5–1 day): we study screens, business logic, data sources. Determine whether Provider is sufficient or a more powerful solution is needed.
- Architecture design (0.5–1 day): draw a dependency graph, decide which Notifiers will be independent and which will be combined.
- Implementation (2–4 days): write code, connect APIs, set up tests.
- Testing and QA (1–2 days): verify correct states, absence of unnecessary rebuilds, test coverage.
- Deployment and documentation (0.5 day): push code, write README, hand over for deployment.
Overall timeline — 5 to 10 working days depending on complexity. Cost is calculated individually after auditing the current code. Order a Provider architecture setup for your project — get clean code without pain.
Typical Mistakes When Setting Up Provider
- Storing state in widgets: use Provider to pass data, do not duplicate in local State.
-
Excessive use of
context.watch: replace withSelectororConsumerfor optimization. -
Ignoring dispose: always free resources in
dispose()of ChangeNotifier (unsubscribe from streams, close connections). - Mixing Provider with other solutions: do not use Provider, BLoC, and GetIt simultaneously — decide on one approach.
Our team has 5+ years of commercial Flutter development experience, over 200 implemented projects. We are certified as Flutter developers (Google Associate Android Developer). We guarantee that the architecture will be scalable and testable. We provide a 60-day warranty on all architectural decisions. Get a consultation on your application's architecture — contact us for an assessment.







