# Approaches to state management

> An introduction to different approaches to managing state in Flutter apps.



State management is a complex topic.
If you feel that some of your questions haven't been answered,
or that the approach described on these pages
is not viable for your use cases, you are probably right.

Learn more from the following resources,
many of which have been contributed by the Flutter community.

## General overview

Things to review before selecting an approach.

* [Introduction to state management][],
  which is the beginning of this very section
  (for those of you who arrived directly to this _Options_ page
  and missed the previous pages)
* [Pragmatic State Management in Flutter][],
  a video from Google I/O 2019
* [Flutter Architecture Samples][], by Brian Egan

[Flutter Architecture Samples]: https://fluttersamples.com/
[Introduction to state management]: /data-and-backend/state-mgmt/intro
[Pragmatic State Management in Flutter]: https://www.youtube.com/watch?v=d_m5csmrf7I

## Built-in approaches

### `setState`

The low-level approach to use for widget-specific, ephemeral state.

* [Adding interactivity to your Flutter app][], a Flutter tutorial
* [Basic state management in Google Flutter][], by Agung Surya

[Adding interactivity to your Flutter app]: /ui/interactivity
[Basic state management in Google Flutter]: https://medium.com/@agungsurya/basic-state-management-in-google-flutter-6ee73608f96d

<a id="valuenotifier-inheritednotifier" aria-hidden="true"></a>

### `ValueNotifier` and `InheritedNotifier`

An approach using only Flutter provided APIs to
update state and notify the UI of changes.

* [State Management using ValueNotifier and InheritedNotifier][], by Tadas Petra

[State Management using ValueNotifier and InheritedNotifier]: https://www.hungrimind.com/articles/flutter-state-management

<a id="inheritedwidget-inheritedmodel" aria-hidden="true"></a>

### `InheritedWidget` and `InheritedModel`

The low-level approach used to
communicate between ancestors and children in the widget tree.
This is what `package:provider` and many other approaches use under the hood.

The following instructor-led video workshop covers how to
use `InheritedWidget`:

<YouTubeEmbed id="LFcGPS6cGrY" title="How to manage application state using inherited widgets"></YouTubeEmbed>

Other useful docs include:

* [InheritedWidget docs][]
* [Managing Flutter Application State With InheritedWidgets][],
  by Hans Muller
* [Inheriting Widgets][], by Mehmet Fidanboylu
* [Widget - State - Context - InheritedWidget][], by Didier Bolelens

[InheritedWidget docs]: https://api.flutter.dev/flutter/widgets/InheritedWidget-class.html
[Inheriting Widgets]: https://medium.com/@mehmetf_71205/inheriting-widgets-b7ac56dbbeb1
[Managing Flutter Application State With InheritedWidgets]: https://blog.flutter.dev/managing-flutter-application-state-with-inheritedwidgets-1140452befe1
[Widget - State - Context - InheritedWidget]: https://flutteris.com/blog/en/widget-state-context-inheritedwidget

## Community-provided packages

Depending on the complexity of your app and preferences of your team,
you might find adopting a state management package useful.
State management packages often help reduce boilerplate code,
provide specialized debugging tools, and can help
enable a clearer and consistent application architecture.

The Flutter community offers a wide variety of state management packages.
The best choice for your app often depends on the app's complexity,
your team's preferences, and the specific problems you need to solve.

To begin exploring the available options,
check out the [`#state-management`][]{: target="_blank"} topic on the pub.dev site and
refine the search to find packages that match your needs.

<div class="card-grid">
  <a class="card outlined-card" href="https://pub.dev/packages?q=topic%3Astate-management" target="_blank">
    <div class="card-header">
      <span class="card-title">
        <span>State management packages</span>
        <Icon id="open_in_new" size="1rem" />
      </span>
    </div>
    <div class="card-content">
      <p>Explore the variety of state-management packages built by and for the Flutter community.</p>
    </div>
  </a>
</div>

:::tip
If you've developed a state management package that
you think would be useful to the Flutter community,
consider [adding the `state-management` topic][pub-topics] and
[publishing the package][pub-publish] to pub.dev.
:::

[`#state-management`]: https://pub.dev/packages?q=topic%3Astate-management
[pub-topics]: https://dart.dev/tools/pub/pubspec#topics
[pub-publish]: https://dart.dev/tools/pub/publishing

