Building a List in Redux with Dart's Flutter Framework

What Will I Learn?

  • You will learn about Redux Architecture and its relationship with the Flutter Framework
  • You will learn how the Flutter Redux and Dart Redux plugins work
  • You will learn how to create Middleware, Actions, Reducers, and State
  • You will learn how to make use of the inherited store widgets from Flutter Redux

Requirements

Difficulty

  • Intermediate

Description

In this Flutter video tutorial, we build a basic list application using the Redux architecture. Redux is a very powerful pattern to use with Flutter because of how Flutter makes use of widget trees. The most popular implementation of Redux for Flutter is the Flutter Redux plugin which makes use of Flutter's inherited widgets to contextually attach pieces of the Redux architecture to the widget tree.

In this application, we have a single action which allows the user to add strings to the list of strings in our state object. We create a reducer function that allows us to specify the business logic of this action for the application to work. We then create a StoreConnector widget which connects our data store to the input box. In this way, we can make it so that when data is passed into our input box, the widget tree will automatically update. The data is then sent into the other StoreConnector widget which is a column of list tile widgets. This widget creates more list tiles every time the user inputs a new piece of data into our input box.

The entire material application widget is wrapped in a StoreProvider Widget which is what allows us to use the StoreConnector widgets to access the store from anywhere in our application. Because of the way that the input box works in this application, we also need to attach a piece of middleware to our add action. In this way, we can add a side effect to our action without breaking the purity of the reducer function. This side effect allows us to take in the input from the input box in a way that lets us serve that input to our state from our action.

The source code for this project can be found here

More info on Facebook's Redux here

Video Tutorial

Curriculum



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
10 Comments