devToolsEnhancer

StoreEnhancer<S> devToolsEnhancer<S>({

  1. String name = 'Store',
  2. void onAction(
    1. Action action,
    2. S prevState,
    3. S nextState
    )?,
  3. bool enabled = true,
})

Dev tools enhancer that logs all actions and state changes.

This provides basic Redux DevTools-like functionality for debugging.

Example:

final store = createStore(
  reducer,
  initialState,
  enhancer: devToolsEnhancer(
    name: 'MyApp',
    onAction: (action, prevState, nextState) {
      print('Action: ${action.type}');
      print('Prev: $prevState');
      print('Next: $nextState');
    },
  ),
);

Implementation

StoreEnhancer<S> devToolsEnhancer<S>({
  String name = 'Store',
  void Function(Action action, S prevState, S nextState)? onAction,
  bool enabled = true,
}) => (createStore, reducer, preloadedState) {
  if (!enabled) return createStore(reducer, preloadedState);

S wrappedReducer(S state, Action action) { final prevState = state; final nextState = reducer(state, action);

onAction?.call(action, prevState, nextState);

return nextState; }

return createStore(wrappedReducer, preloadedState); };