Flutter State Management Guide From setState to Riverpod and Bloc

Flutter State Management Guide From setState to Riverpod and Bloc

Flutter state management is how your app holds changing data and rebuilds the widgets that show it. A cart total, a signed-in user and a selected tab are all examples of state. Flutter's official docs list the built-in tools and recommend no single package.

Our short answer for most teams is simple. Use setState for data that lives inside one widget. For shared data, pick Riverpod or Bloc and apply it the same way everywhere. This guide explains each option, shows small examples and gives you a framework for choosing.

Key takeaways

  • Flutter splits state into ephemeral state, kept inside one widget, and app state, shared across screens.
  • setState, ValueNotifier and InheritedWidget ship with Flutter and need no extra package.
  • Provider, Riverpod and Bloc are popular community packages, and the official docs endorse none of them.
  • In our opinion, Riverpod suits most new apps and Bloc suits large teams that want strict event flows.
  • Pick one approach for shared state and document it, rather than mixing several packages.

What is state in a Flutter app?

State is any data that can change while the app runs and that affects what the screen shows. Widgets describe the interface for the current state. When that state changes, Flutter runs the build method again and redraws what changed.

The docs split state into two kinds. Ephemeral state lives inside a single widget, like the current page of a PageView or the progress of an animation. App state is shared across many parts of the app, like login details, user preferences or a shopping cart.

Flutter's guide to ephemeral and app state admits there is no clear rule for telling the two apart. A tab index can be ephemeral in a small app and become app state later. The page quotes Redux author Dan Abramov's rule of thumb, “Do whatever is less awkward.”

What built-in state management tools does Flutter include?

Flutter ships three families of tools for state, and none of them needs a package from pub.dev, the public registry where Dart developers share packages.

setState for data inside one widget

setState is a method on the State object of a StatefulWidget. You change a field inside the callback you pass to it, and Flutter rebuilds that widget. A counter button is the classic example, written as setState(() => _count++) inside the tap handler.

It suits form fields, toggles and animations with zero setup. It stops scaling once two distant screens need the same data, because values and callbacks then travel through many constructors.

ValueNotifier, ChangeNotifier and ListenableBuilder

A ValueNotifier holds one value and tells its listeners when that value changes. You wrap the dependent part of the UI in a ValueListenableBuilder, so only that subtree rebuilds. This works well for a theme switch or a loading flag that a few widgets read.

ChangeNotifier is the version for classes with several fields. Your model extends it, updates its fields and calls notifyListeners when something changes. A ListenableBuilder then rebuilds only the widgets that listen to that model.

InheritedWidget and InheritedModel

InheritedWidget makes data available to every widget below it in the tree without passing it through constructors. Flutter's own Theme and MediaQuery are built on this mechanism. InheritedModel adds aspects, so a widget can rebuild only when the slice it depends on changes.

Writing these classes by hand takes boilerplate, meaning repetitive setup code. The official list of state management options notes that package:provider and many other approaches use InheritedWidget under the hood.

Which state management packages do Flutter teams use?

Most production apps add a package once several screens share data. These are the ones you will meet most often in job listings and codebases.

Provider

Provider describes itself as a wrapper around InheritedWidget that makes it easier to use and reuse. You place a ChangeNotifierProvider above the widgets that need a model. Widgets below it read the model through their BuildContext with the watch and read extension methods.

Provider had about 11,000 likes on pub.dev as of November 2026, more than Riverpod or flutter_bloc. It remains a reasonable choice for small apps and for existing codebases. Its main drawback is that a missing provider shows up as a runtime error, not a compile error.

Riverpod

Riverpod comes from the same pub.dev publisher as Provider and calls itself a reactive caching and data-binding framework. Providers are declared outside the widget tree, so any widget or test can reach them. Its site says common mistakes become compilation errors instead of runtime crashes.

Async providers expose loading, data and error states, which suits screens backed by network calls. The current examples use annotations with code generation, which adds a build step to your workflow. Newcomers often find the number of provider types confusing for the first week or two.

As of November 2026, the latest flutter_riverpod release was version 3.5.0.

Bloc and Cubit

Bloc stands for Business Logic Component. The flutter_bloc package provides widgets that make the BLoC design pattern easy to implement. A Bloc receives events, processes them and emits new states, so every change follows one traceable path.

Cubit is the lighter form of the same idea. It exposes plain methods instead of events, which cuts boilerplate for simple features. The same widgets, such as BlocBuilder and BlocListener, work with both Bloc and Cubit.

Bloc asks for more classes and files than the other options. Large teams often accept that cost because the structure makes reviews and tests predictable. As of November 2026, flutter_bloc had about 8,090 likes on the pub.dev registry.

GetX and Redux

GetX bundles state, routing and dependency injection in one package. In our view, that coupling makes large apps harder to test and to migrate away from later.

Redux, through flutter_redux, ports the single-store pattern from JavaScript. In our opinion, Bloc and Riverpod cover the same needs with less ceremony, so we would not start a new Flutter project on Redux.

Flutter state management options compared

Comparison of Flutter state management approaches including setState, Provider, Riverpod and Bloc

ApproachShips with FlutterBoilerplateBest forMain limitation
setStateYesVery lowLocal UI state in one widgetGets messy when screens share data
ValueNotifier and ChangeNotifierYesLowSmall shared values and simple modelsNo built-in pattern for async work or dependencies
InheritedWidget and InheritedModelYesHighLow-level sharing or building your own solutionVerbose to write by hand
ProviderNo, packageLowSmall to medium apps and existing codebasesMissing providers fail at runtime
RiverpodNo, packageMediumMost new apps, async data, testable logicMany provider types and a code generation step
Bloc and CubitNo, packageHigh for Bloc, medium for CubitLarge teams and complex, auditable flowsMore classes and files per feature
GetXNo, packageLowQuick prototypesCouples state, routing and dependency injection

The boilerplate ratings and best-fit notes are our own judgement from typical usage, not measured benchmarks.

How do you choose the right approach for your app?

Work through these questions in order. Most teams have an answer by the third one.

  1. Do several screens share this data? If not, use setState and stop there.
  2. Does most of your state come from APIs or databases? Riverpod's async providers keep loading and error handling short.
  3. Will many developers work on the same features? Bloc's event and state classes keep everyone's code shaped the same way.
  4. Is there an existing app? Keep its current approach unless it causes real bugs, and migrate one feature at a time. A Flutter app audit can map where state lives before you change anything.
  5. What does your team already know? A familiar tool used well beats a better tool used badly.

For a typical startup first release, we would start with Riverpod for shared data and setState for local data. Our guide to building an MVP with Flutter covers the rest of that stack.

How does one feature look in Riverpod and in Bloc?

Take a shopping cart that several screens read. In Riverpod, you declare a Notifier class that holds a list of items and offers add and remove methods. Any widget that shows the total watches that provider and rebuilds when the list changes.

In Bloc, you define events such as ItemAdded and ItemRemoved, plus a CartState that holds the items. The CartBloc maps each event to a new state. Screens wrap their cart UI in a BlocBuilder, and the checkout button uses a BlocListener to show errors.

Both versions keep cart logic out of the widgets, and both are easy to unit test. The Riverpod version is shorter to write. The Bloc version records every change as a named event, which some teams value for debugging and audits.

What are the most common state management mistakes?

Good practices for managing state in a Flutter app

  • Making everything global. Form input and animation values belong in setState, not in a shared store.
  • Mixing several packages. Two shared-state systems in one codebase confuse new developers and duplicate logic.
  • Changing state in place. Editing a list inside a state object may not notify listeners, so create a new copy instead. Packages such as freezed generate immutable classes with copyWith methods.
  • Rebuilding too much. Watch only the value a widget needs, and split large widgets so small changes stay small.
  • Calling APIs inside build methods. Build can run many times, so trigger network calls from your state layer.
  • Skipping tests. Logic in a Notifier, Cubit or Bloc can be tested without rendering any widgets.

Frequently asked questions

Which state management is best for Flutter?

No single option is best for every app, and Flutter's docs do not recommend one. Use setState for data inside one widget. In our view, Riverpod suits most new apps and Bloc suits large teams that want strict structure.

Is Provider still a good choice?

Provider still works and is widely used, with about 11,000 likes on Dart's package registry as of November 2026. It suits small apps and existing projects well. For new apps with a lot of async data, we would usually pick Riverpod instead.

What is the difference between Bloc and Cubit?

A Bloc receives events and maps them to new states. A Cubit skips events and exposes plain methods that emit states. Both use the same flutter_bloc widgets, so you can start with Cubit and move a feature to Bloc later.

What is the difference between ephemeral state and app state?

Ephemeral state lives inside one widget, such as a selected tab or an animation value. App state is shared across screens or kept between sessions, such as login details or a cart. Flutter's docs say the line between them is a judgement call.

Can I mix setState with Riverpod or Bloc?

Yes, and most well-structured apps do exactly that. Keep purely visual, local data in setState and put shared business data in your chosen package. The mistake to avoid is running two shared-state packages side by side.

How hard is it to switch state management later?

Switching is possible but takes time, because state code touches most screens. Teams usually migrate one feature at a time while both approaches run together. Plan the move only when the current approach is causing real bugs or slowing delivery.

Which approach should you start with?

Start with setState for local data and choose one package for shared data. Riverpod is our default suggestion for new apps, and Bloc fits larger teams that want strict structure. Whatever you pick, write it down and apply it the same way across features.

Talk to Flutter developers about state management for your app

You can also hire Flutter developers experienced with Riverpod and Bloc, starting with a one-week free trial.