对不起,如果答案很明显,但我傻眼了。我对 redux 来说是全新的,它开始变得有意义了。我正在尝试使用中间件来保持 reducer 的纯函数,但它给了我一个我不明白的错误。我正在关注 redux 的颤振架构样本

void main() {
  final store = Store<AppState>(
    appReducer,
    initialState: AppState.loading(),
    middleware: createStoreFlashCardsMiddleware(),
  );
  runApp(new MyApp(store));
}

//the 中间件

List<Middleware<AppState>> createStoreFlashCardsMiddleware() {
  final loadFlashCards = _createLoadFlashCardsMiddleware();
  final saveFlashCards = _createSaveFlashCardsMiddleWare();

  return [
    TypedMiddleware<AppState, FetchFlashCardsAction>(loadFlashCards),
    TypedMiddleware<AppState, AddFlashCardAction>(saveFlashCards),
    TypedMiddleware<AppState, ClearCompletedAction>(saveFlashCards),
    TypedMiddleware<AppState, ToggleAllAction>(saveFlashCards),
    TypedMiddleware<AppState, UpdateFlashCardAction>(saveFlashCards),
    TypedMiddleware<AppState, FetchCardsSucceededAction>(saveFlashCards),
    TypedMiddleware<AppState, DeleteFlashCardAction>(saveFlashCards),
  ];
}

Middleware<AppState> _createSaveFlashCardsMiddleWare() {
  return (Store store, action, NextDispatcher next) async {
  // YOUR LOGIC HERE
  // After you do whatever logic you need to do,
  // call this Redux built-in method,
  // It continues the redux cycle.
  next(action);
  };
}

Middleware<AppState> _createLoadFlashCardsMiddleware() {
  return (Store store, action, NextDispatcher next) async {
  next(action);
  };
}

错误是:

error: The argument type 'List<(Store<AppState>, dynamic, (dynamic) → void) → void> (C:\flutter\bin\cache\pkg\sky_engine\lib\core\list.dart)' can't be assigned to
the parameter type 'List<(Store<AppState>, dynamic, (dynamic) → void) → void> (C:\flutter\bin\cache\pkg\sky_engine\lib\core\list.dart)'. (argument_type_not_assignable at [line])