redux_future 0.1.3

  • Installing
  • Versions
  • 88


Build Status codecov

A Redux Middleware for handling Dart Futures as actions, with support for loading & optimistic payloads.

The futureMiddleware can be attached to the Redux Store upon construction.

Once attached, you can store.dispatch a Future or FutureAction, and the futureMiddleware will intercept it.

  • If the Future / FutureAction completes successfully, a FutureFulfilledAction will be dispatched with the result of the future.
  • If the Future / FutureAction fails, a FutureRejectedAction will be dispatched containing the error that was returned.


main() {
  // First, create a reducer that knows how to handle the Future Actions:
  // `FutureFulfilledAction` and `FutureRejectedAction`.
  String exampleReducer(String state, action) {
    if (action is String) {
      return action;
    } else if (action is FutureFulfilledAction<String>) {
      return action.result;
    } else if (action is FutureRejectedAction<Exception>) {
      return action.error.toString();
    return state;
  // Next, create a Store that includes `futureMiddleware`. It will
  // intercept all `FutureAction`s that are dispatched.
  final store = new Store(
    middleware: [futureMiddleware],
  // Next, dispatch some actions!
  // In this example, once the Future completes, a `FutureFulfilledAction`
  // will be dispatched with "Hi" as the result. The `exampleReducer` will
  // take the result of this action and update the state of the Store!
  store.dispatch(new Future.value("Hi"));
  // In this example, the initialAction String "Fetching" will be
  // immediately dispatched. After the future completes, the
  // "Search Results" will be dispatched.
  store.dispatch(new FutureAction(
    new Future.value("Search Results"),
    initialAction: "Fetching"));
  // In this example, the future will complete with an error. When that
  // happens, a `FutureRejectedAction` will be dispatched to your store,
  // and the state will be updated by the `exampleReducer`.
  store.dispatch(new Future.error("Oh no!"));




  • Dispatch initialAction through the entire Middelware chain. Fix contributed by Kezhu Wang!


  • Fix FutureAction incorrect type parameter. Fix contributed by Kezhu Wang!


  • Move to Github
  • Add the ability to await the resulting action (Fulfilled or Rejected) after it has been dispatched to the store.
  • Added FutureResultAction as base class for Fulfilled / Rejected actions.


  • Initial version, includes a futureMiddleware that intercepts Futures and FutureActions, captures their results, and dispatches their results as Redux actions.
  • Included classes
    • FutureAction
    • FutureFulfilledAction
    • FutureRejectedAction

Use this package as a library

1. Depend on it

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

  redux_future: "^0.1.3"

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 flutter 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_future/redux_future.dart';
Version Uploaded Documentation Archive
0.1.3 Dec 4, 2017 Go to the documentation of redux_future 0.1.3 Download redux_future 0.1.3 archive
0.1.2 Dec 4, 2017 Go to the documentation of redux_future 0.1.2 Download redux_future 0.1.2 archive
0.1.1 Nov 26, 2017 Go to the documentation of redux_future 0.1.1 Download redux_future 0.1.1 archive
0.1.0 Aug 27, 2017 Go to the documentation of redux_future 0.1.0 Download redux_future 0.1.0 archive


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
77 / 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]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:redux_future/redux_future.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.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use redux_future.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <2.0.0
redux >=2.0.0 <3.0.0 2.1.1 3.0.0
Dev dependencies
test ^0.12.0