MockStore<St> class Null safety

Creates a Redux store that lets you mock actions/reducers.

The MockStore lets you define mock actions/reducers for specific actions.

For more info, see:



MockStore({required St initialState, bool syncStream = false, TestInfoPrinter? testInfoPrinter, List<ActionObserver<St>>? actionObservers, List<StateObserver<St>>? stateObservers, Persistor<St>? persistor, ModelObserver? modelObserver, ErrorObserver<St>? errorObserver, WrapError<St>? wrapError, bool defaultDistinct = true, Map<Type, dynamic>? mocks})


defaultDistinct bool
read-only, inherited
dispatchCount int
read-only, inherited
errors Queue<UserException>
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
immutableCollectionEquality CompareBy?
  • If null (the default), view-models which are immutable collections will be compared by their default equality.

  • If CompareBy.byDeepEquals, view-models which are immutable collections will be compared by their items, one by one (potentially slow comparison).

  • If CompareBy.byIdentity, view-models which are immutable collections will be compared by their internals being identical (very fast comparison).

  • [...]
    read-only, inherited
    isShutdown bool
    read-only, inherited
    mocks Map<Type, dynamic>?
  • null to disable dispatching the action of a certain type.

  • A MockAction<St> instance to dispatch that action instead, and provide the original action as a getter to the mocked action.

  • A ReduxAction<St> instance to dispatch that mocked action instead.

  • ReduxAction<St> Function(ReduxAction<St>) to create a mock from the original action.

  • St Function(ReduxAction<St>, St) or Future<St> Function(ReduxAction<St>, St) to modify the state directly.

  • read / write
    modelObserver ModelObserver?
    read-only, inherited
    onChange Stream<St>
    A stream that emits the current state when it changes. [...]
    read-only, inherited
    onReduce Stream<TestInfo<St>>
    Used by the storeTester.
    read-only, inherited
    reduceCount int
    read-only, inherited
    runtimeType Type
    A representation of the runtime type of the object.
    read-only, inherited
    state → St
    The current state of the app.
    read-only, inherited
    stateTimestamp DateTime
    The timestamp of the current state in the store, in UTC.
    read-only, inherited
    testInfoPrinter TestInfoPrinter?
    read-only, inherited


    addMock(Type actionType, dynamic mock) MockStore<St>
    addMocks(Map<Type, dynamic> mocks) MockStore<St>
    clearMocks() MockStore<St>
    createTestInfoSnapshot(St state, ReduxAction<St> action, Object? error, Object? processedError, {required bool ini}) → void
    defineState(St state) → void
    Beware: Changes the state directly. Use only for TESTS.
    dispatch(ReduxAction<St> action, {bool notify = true}) Future<ActionStatus>
    Runs the action, applying its reducer, and possibly changing the store state. Note: store.dispatch is of type Dispatch.
    getAndRemoveFirstError() UserException?
    Gets the first error from the error queue, and removes it from the queue.
    initTestInfoController() → void
    Turns on testing capabilities, if not already.
    initTestInfoPrinter(TestInfoPrinter testInfoPrinter) → void
    Changes the testInfoPrinter.
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a non-existent method or property is accessed. [...]
    shutdown() → void
    Call this method to shut down the store. It won't accept dispatches or change the state anymore.
    teardown({St? emptyState}) 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
    A string representation of this object. [...]
    waitCondition(bool condition(St), {int? timeoutInSeconds}) Future<void>
    Returns a future which will complete when the given condition is true. The condition can access the state. You may also provide a timeoutInSeconds, which by default is null (never times out).


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