Skip to content
pubscout

redux_thunk

0.4.0, released 6 years ago by an unverified publisher

A Redux middleware that allows dispatching async functions as actions.

WASM-ready
$ flutter pub add redux_thunk
Source repository

What it does

Provides thunkMiddleware to intercept and execute ThunkActions in a Redux store. Enables performing asynchronous work and dispatching subsequent actions.

AI-written summary of version 0.4.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using Redux.dart and need to handle asynchronous operations.
  • You want to dispatch functions that take the Store as an argument.

Skip it when

  • You are not using the Redux state management pattern.
  • You prefer modern state management alternatives like Riverpod or Bloc.

Strengths

  • Enables asynchronous work in Redux architectures.
  • Simple API with a single thunkMiddleware.

Weaknesses

  • Limited to Redux.dart ecosystem.
  • No advanced side-effect handling features beyond basic functions.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

Add thunkMiddleware to your Redux Store middleware list.

final store = new Store<String>(
  reducer,
  middleware: [thunkMiddleware],
);

void action(Store<String> store) async {
  final searchResults = await new Future.delayed(
    new Duration(seconds: 1),
    () => "Search Results",
  );

  store.dispatch(searchResults);
}

Alternatives

Packages that do the same job and could replace redux_thunk.

  • bloc

    Provides a predictable state management solution with built-in stream and async support without Redux boilerplate.

  • riverpod

    A robust, modern state management library supporting async operations natively.

Works with

Packages commonly used together with redux_thunk: ones it builds on, ones built on it, and its own family.