Store<State> class

Creates a Redux store that holds the app state tree.

The only way to change the state tree in the store is to dispatch an action. the action will then be intercepted by any provided Middleware. After running through the middleware, the action will be sent to the given Reducer to update the state tree.

To access the state tree, call the state getter or listen to the onChange stream.

Basic Example

// Create a reducer
final increment = 'INCREMENT';
final decrement = 'DECREMENT';

int counterReducer(int state, action) {
  switch (action) {
    case increment:
      return state + 1;
    case decrement:
      return state - 1;
      return state;

// Create the store
final store = new Store<int>(counterReducer, initialState: 0);

// Print the Store's state.
print(store.state); // prints "0"

// Dispatch an action. This will be sent to the reducer to update the
// state.

// Print the updated state. As an alternative, you can use the
// `store.onChange.listen` to respond to all state change events.
print(store.state); // prints "1"


Store(Reducer<State> reducer, {State initialState, List<Middleware<State>> middleware: const [], bool syncStream: false, bool distinct: false})
Creates an instance of a Redux Store. [...]


hashCode int
The hash code for this object. [...]
read-only, inherited
onChange Stream<State>
A stream that emits the current state when it changes. [...]
reducer Reducer<State>
The Reducer for your Store. Allows you to get the current reducer or replace it with a new one if need be.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
state → State
Returns the current state of the app


dispatch(dynamic action) → dynamic
Runs the action through all provided Middleware, then applies an action to the state using the given Reducer. Please note: Middleware can intercept actions, and can modify actions or stop them from passing through to the reducer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
teardown() Future
Closes down the Store so it will no longer be operational. Only use this if you want to destroy the Store while your app is running. Do not use this method as a way to stop listening to onChange state changes. For that purpose, view the onChange documentation.
toString() String
Returns a string representation of this object.


operator ==(Object other) bool
The equality operator. [...]