1

我正在尝试更新flutter redux中的一些属性,但出现以下错误

Class 'DivMatches' has no instance setter 'id='.

这是我的州课

class AppState {
  var demoState;
  List myMatches;

  AppState({this.demoState, this.myMatches});

  AppState copywith({demoState, myMatches}){
  return AppState(
     myMatches : myMatches ?? this.myMatches,
     demoState: demoState ?? this.demoState,
  );

 }
}

我的动作看起来像这样

class UpdateDivResult{ // update the div result by id
  dynamic id;
  UpdateDivResult(this.id);
 }

我的减速机看起来像这样

   var newMatch = state.myMatches[0][0];
    newMatch.id = 223;

    return state.copywith(
       myMatches: newMatch
    );

请帮忙。太感谢了。

4

1 回答 1

1

问题是,我在 json serializeble 中使我的变量最终化。删除 final 将允许您更新。

于 2019-06-02T20:11:19.790 回答