【发布时间】:2022-02-26 03:09:04
【问题描述】:
List<TestModel> lists = List();
FutureBuilder<List<TestModel>>(
future: testNetworkRepository.fetchAlltext(TestModel.testKey),
builder: (context, snapshot){
if(snapshot.hasData){
lists = snapshot.data;
return Contanier();
}
}
)
Future _editText(int index, String testKey) async {
await showDialog(
context: context,
child: SimpleDialog(
children: [
SimpleDialogOption(
child: TextButton(
child: Text("Edit"),
onPressed: (){
setState(() {
lists[index].text = editTextController.text; <- error occured
});
},
),
)
],
)
);
}
这是我的代码。我要编辑lists[index].text。
但是发生了错误。
'text' 不能用作 setter,因为它是 final。
我该如何解决这个问题?
【问题讨论】:
-
你能粘贴整个代码吗?