redux 2.1.1

  • Installing
  • Versions
  • 98


Build Status

Redux for Dart using generics for typed State. It includes a rich ecosystem of Docs, Middleware, Dev Tools and platform integrations.


import 'package:redux/redux.dart';

// Create typed actions. You will dispatch these in order to
// update the state of your application.
enum Actions {

// Create a Reducer. A reducer is a pure function that takes the 
// current State (int) and the Action that was dispatched. It should
// combine the two into a new state without mutating the state passed
// in! After the state is updated, the store will emit the update to 
// the `onChange` stream.
// Because reducers are pure functions, they should not perform any 
// side-effects, such as making an HTTP request or logging messages
// to a console. For that, use Middleware.
int counterReducer(int state, action) {
  if (action == Actions.increment) {
    return state + 1;
  } else if (action == Actions.decrement) {
    return state - 1;
  return state;

// A piece of middleware that will log all actions with a timestamp
// to your console!
// Note, this is just an example of how to write your own Middleware.
// See the redux_logging package on pub for a pre-built logging 
// middleware.
loggingMiddleware(Store<int> store, action, NextDispatcher next) {
  print('${new}: $action');


main() {
  // Create the store with our Reducer and Middleware
  final store = new Store<int>(
    initialState: 0, 
    middleware: [loggingMiddleware],

  // Render our State right away
  // Listen to store changes, and re-render when the state is updated

  // Attach a click handler to a button. When clicked, the `INCREMENT` action
  // will be dispatched. It will then run through the reducer, updating the 
  // state.
  // After the state changes, the html will be re-rendered by our `onChange`
  // listener above. 
  querySelector('#increment').onClick.listen((_) {

render(int state) {
  querySelector('#value').innerHtml = '${state}';


  • Motivation and Principles - Learn why Redux might make sense for your app and the principles behind it.
  • Basics - Introduction to the core concepts in Redux
  • Async - Learn how to make async calls, such as to a web service or local database, with Redux.
  • Combining Reducers - combineReducers works a bit differently in Dart than it does in JS. Learn why, and how to combine reducers in a type-safe way!
  • API Documentation - Rich documentation included in the source code and generated by DartDoc.

Flutter Examples

Web Examples

See the example/ directory for a few simple examples of the basics of Redux.

To launch the examples in your browser:

  1. Run pub serve example from this directory
  2. Open http://localhost:8080


  • redux_logging - Connects a Logger to a Store, and can print out actions as they're dispatched to your console.
  • redux_thunk - Allows you to dispatch functions that perform async work as actions.
  • redux_future - For handling Dart Futures that are dispatched as Actions.
  • redux_epics - Middleware that allows you to work with Dart Streams of Actions to perform async work.

Platform Integrations

Dev Tools

The redux_dev_tools library allows you to create a DevToolsStore during dev mode in place of a normal Redux Store.

This DevToolsStore will act exactly like a normal Store at first. However, it will also allow you to travel back and forth throughout the States of your app or recompute the State of your app by replaying all actions through your reducers. This works perfectly with Hot Reloading!

You can combine the DevToolsStore with your own UI to travel in time, or use one of the existing options for the platform you're working with:

Additional Utilities

  • reselect - Efficiently derive data from your Redux Store with memoized functions.


  • Ensure the repo is 100% healthy.


  • Add the distinct option. If set to true, the Store will not emit onChange events if the new State that is returned from your [reducer] in response to an Action is equal to the previous state. False by default.


  • Use absolute urls to fix broken links in documentation on Pub.


  • Add MOAR documentation


  • Add type-safe combineTypedReducers and combineTypedMiddleware functions


  • Add documentation highlighting the redux ecosystem


  • Breaking API Changes:
    • Reducer is now a typedef. Use ReducerClass<State> if you'd like to continue to use a class interface.
    • Middleware is now a typedef. Use MiddlewareClass<State> as a replacement for the old Middleware<State, Action>
    • A teardown method has been added. Use it to shut down the store in the middle of your application lifecycle if you no longer need the store.
  • Added more docs

1. Depend on it

Add this to your package's pubspec.yaml file:

  redux: "^2.1.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:redux/redux.dart';
Version Uploaded Documentation Archive
2.1.1 Jan 3, 2018 Go to the documentation of redux 2.1.1 Download redux 2.1.1 archive
2.1.0 Dec 22, 2017 Go to the documentation of redux 2.1.0 Download redux 2.1.0 archive
2.0.4 Nov 29, 2017 Go to the documentation of redux 2.0.4 Download redux 2.0.4 archive
2.0.3 Nov 29, 2017 Go to the documentation of redux 2.0.3 Download redux 2.0.3 archive
2.0.2 Nov 4, 2017 Go to the documentation of redux 2.0.2 Download redux 2.0.2 archive
2.0.1 Sep 5, 2017 Go to the documentation of redux 2.0.1 Download redux 2.0.1 archive
2.0.0 Aug 25, 2017 Go to the documentation of redux 2.0.0 Download redux 2.0.0 archive
1.1.0 Sep 7, 2016 Go to the documentation of redux 1.1.0 Download redux 1.1.0 archive
1.0.0 May 17, 2016 Go to the documentation of redux 1.0.0 Download redux 1.0.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
96 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:redux/redux.dart.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use redux.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
Dev dependencies
browser >=0.10.0+2 <0.11.0
test >=0.12.24+2 <0.13.0