Search code examples
flutterdartstatestate-management

What do we actually mean by "State" in State management?


Can anyone please explain in simple terms, what is a State and what is State Management? (I'm using Flutter but I'm open to both general and Flutter/Dart specific answers)

I'm just trying to learn the core idea behind the concept.


Solution

  • In its most general form, state is the everything that would need to be restored to return to a particular point in time. The scope also has to be defined, since it's not reasonable to move planets backwards in their orbits, so you'll generally have an app state, or a widget state, or possibly separate states within an app (a game board that changes while the high score section doesn't until the game ends with a new high score).

    The Flutter documentation is a pretty good description on what it is, why, and how to do it:

    https://docs.flutter.dev/data-and-backend/state-mgmt/intro

    https://docs.flutter.dev/data-and-backend/state-mgmt/simple

    Often changes to the state are stored in a buffer allowing you to undo them or redo them in sequence, or they can be saved as a checkpoint to restart after a crash or forced quit/suspend (depends on the app environment).