Last year, while we were still on the agency side, we took over a Flutter project that another agency had left half-finished. When we opened the codebase, we were greeted by a 4,000-line "AppState" class: the user session, the cart, the notification counter, the theme preference, even the scroll position of one screen — all in the same giant object, in a setup where half the screen was redrawn on every change. The client's complaint was a familiar one: "The app sometimes freezes, sometimes a screen doesn't update, sometimes the same list refreshes three times." We weren't surprised. I've lost count of how many projects in which we've heard that exact complaint, word for word.
The number one source of technical debt in Flutter projects is scattered state management. The innocent journey that starts with setState turns, as the project grows, into the riddle of "why isn't this screen refreshing / why is it refreshing three times?" The answer I've been giving in production for years hasn't changed: Riverpod + layered architecture. In this post I won't give you the marketing pitch; I'll explain why it works in the field.
The end of the road that starts with setState
Don't get me wrong: setState isn't bad. For a single-screen form or a small piece of animation state, it's perfectly appropriate. The problem appears as the app grows and state starts being shared across screens. The number of items in the cart needs to appear on the home screen, on the product detail page and in the checkout step; the user profile matters to five different screens. At this point developers either pass the data down the widget tree by hand (unbearable after three levels), or escape to global variables (untestable, untraceable), or that infamous god object, AppState, is born.
All three lead to the same place: a tangle where it's unclear who updates what and when, and where debugging takes hours. On that project we measured that updating a single field caused seven screens to redraw — that was what the user called "freezing."

Why we chose Riverpod, and why we still haven't given it up
The first Riverpod feature that won us over was compile-time safety. Providers can be safely accessed even from outside the widget tree; a dependency placed at the wrong level of the tree blowing up at runtime — that infamous "ProviderNotFound" surprise — goes down in history as an entire class of bugs. If there's an error, you see it at compile time, not on the user's phone.
Second, the dependency graph. Providers watch each other: when the source data changes, every state derived from it updates automatically. You don't write manual synchronization code along the lines of "the cart changed, don't forget to update the total by hand, and trigger the shipping calculation too" — there's nothing left to forget. A significant share of the bugs in the projects I've inherited over the years belong to exactly this family: "derived state someone forgot to sync."
Third, and the hardest to explain to the business side: testability. Every provider can be tested in isolation by supplying fake dependencies through the override mechanism. UI tests no longer need a real API or a real database. We found the answer to "doesn't writing tests make everything take longer?" while trying to safely rip out that 4,000-line AppState — refactoring code that has no tests is like performing surgery in the dark.
So is there no downside at all? There is: the learning curve. Riverpod's many provider types and its code generation layer can feel overwhelming to a team at first contact. Our solution was to pin the patterns used in our projects down to three or four templates — not everyone uses every feature, just the subset we chose as a team. You don't have to use the entire framework; consistency is worth more than coverage.

Three layers, one direction: our setup
Riverpod on its own isn't an architecture; it pays off when combined with discipline. Our standard is three layers with one-way flow: the Data layer holds the API and database repositories; in the Domain layer, business rules live as pure Dart (not a single import from Flutter — which lets the business logic be tested independently of the framework); the Presentation layer holds the widgets and providers. A widget only reads providers and declares intent: "the user tapped this button." Business rules never leak into the build method.

On the async side, AsyncValue was a game changer for us. Loading, error and data — three states flow through a single type; the era of keeping a separate "isLoading" flag on every screen and forgetting one of them is over. Bugs of the "the loading flag wasn't updated, the screen got stuck on an endless spinner" variety are eliminated at the root. In code reviews, we don't even look for that class of bug anymore.
The layers have a human side, too. The developer on the Data layer focuses on the API contract, the one on Domain on business rules, the one on Presentation on screen behavior; all three can work in parallel without stepping on each other's toes. Even on small teams this separation pays off, because when you come back to your own code six months later, the question "where does this rule live?" has a single answer. The developer who writes the same logic a second time because they couldn't find the original is the quietest producer of technical debt.
Three rules proven in the field
Years of experience fit into three rules. First: one top-level provider per screen, with small, focused providers beneath it. A giant "AppState" god object is forbidden — the fact that something can be accessed from everywhere doesn't mean it should be. Second: ref.watch inside build, ref.read in callbacks. Flip this around and your screen either never updates or thrashes; it's the rule we teach every new developer in their first week, because violating it is the most expensive mistake. Third: make autoDispose the default; choose deliberately which state you want to keep alive. Otherwise memory fills up with the state of pages the user left three screens ago, and you only notice it in crash reports from low-RAM devices.
(And a bonus: set a team standard for provider naming. If we come across a provider named "dataProvider2," you can probably guess what the rest of that codebase looks like.)
Let me not skip debugging either: because the providers' dependency graph is observable, we now answer the question "why did this screen redraw?" by tracing rather than guessing. Which provider fired, and what triggered it — the whole chain is right there. In the setState world, hunting for that answer meant a print-statement safari; now it's a few minutes of routine work.
So what was the result? We migrated that project to this setup gradually — no big bang, screen by screen. Four months later the crash rate had dropped measurably, and the "screen doesn't update" complaint had disappeared from support tickets. In general, in the apps we've built with this setup, the time it takes a new developer to become productive drops from weeks to days, because everything has a place and that place is predictable.
If you have a Flutter project that has grown big and worn out, and you're wondering "do we have to rewrite it from scratch to fix it?" — most of the time, you don't. Gradual migration is possible; I've done it many times, and I'm speaking from experience. Rewriting from scratch is a tempting dream; gradual migration is a plan that works — and your users keep using the app in the meantime, which is the whole point. I'm always open to discussions about Riverpod and architecture; the contact page is waiting.