本文介绍了如何在flutter redux中更新列表的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新flutter redux中的某些属性,但出现以下错误
I am trying to update some property in flutter redux but i am getting the following error
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);
}
我的减速器看起来像这样
My reducer looks like this
var newMatch = state.myMatches[0][0];
newMatch.id = 223;
return state.copywith(
myMatches: newMatch
);
请帮助.非常感谢.
推荐答案
问题是,我在json serializeble中将变量定为final.删除final将允许您更新.
The problem was, I made my variables final in json serializeble. removing final will allow you to update.
这篇关于如何在flutter redux中更新列表的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!