DEV Community


Flutter Redux Tutorial - A simple practical Flutter Redux example

loizenai profile image loizenai ・1 min read

Flutter Redux Tutorial - A simple practical Flutter Redux example

In this Flutter Redux tutorial, we’re gonna introduce main concept of Redux: what it is, how to work with Redux Store, Action, Reducers. Then we will practice to understand all of them with a simple practical Flutter Redux example.

Flutter Redux Overview


Redux is a state container that helps applications to manage state.
=> Whenever we wanna read the state, look into only one single place - Redux Store.
=> Managing the state could be simplified by dealing with simple objects and pure functions.

Redux Store

Store holds the current state so that we can see it as a single source of truth for our data.

class MyAppState {
  final int counter;

final store = new Store(counterReducer, initialState: MyAppState(0));

Redux Action

Action is payload of information that is sent to Store using store.dispatch(action).
Action must have a type property that should typically be defined as string constants. It indicates the type of action being performed:

  'type': Actions.INCREMENT
  'number': 3

  'type': Actions.DECREMENT
  'number': 2

Discussion (0)

Editor guide