gpt4 book ai didi

flutter - 如何在flutter redux中更新列表的属性

转载 作者:行者123 更新时间:2023-12-03 03:01:47 26 4
gpt4 key购买 nike

我正在尝试更新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,
);

}
}

我的 Action 看起来像这样
class UpdateDivResult{ // update the div result by id
dynamic id;
UpdateDivResult(this.id);
}

我的 reducer 看起来像这样
   var newMatch = state.myMatches[0][0];
newMatch.id = 223;

return state.copywith(
myMatches: newMatch
);

请帮忙。非常感谢。

最佳答案

问题是,我将变量最终定为json可序列化。删除最终版本将允许您进行更新。

关于flutter - 如何在flutter redux中更新列表的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56413534/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com