DEV Community

loizenai
loizenai

Posted on

Flutter Redux Tutorial - A simple practical Flutter Redux example

Flutter Redux Tutorial - A simple practical Flutter Redux example

https://grokonez.com/flutter/flutter-redux-tutorial-flutter-redux-example-a-simple-practical

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

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.


@immutable
class MyAppState {
  final int counter;
  MyAppState(this.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
}

https://grokonez.com/flutter/flutter-redux-tutorial-flutter-redux-example-a-simple-practical

Top comments (1)

Collapse
 
pablonax profile image
Pablo Discobar

Wow, cool article! If you are interested in this topic, then look here dev.to/pablonax/flutter-templates-...