flutter - 如何在方法中编辑最终类字段?
问题描述
我想用这样的方法编辑我的字段:
class Test extends StatefulWidget{
Test({this.firstField, this.secondField});
final String firstField ;
final String secondField ;
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
@override
Widget build(BuildContext context) {
return null;
}
editField( field, newValue){
//edit any field of the class in a single function here
}
}
如果我将widget.firstField
其用作方法的第一个参数,我将能够在本地(在方法中)进行编辑,但不能在字段中进行编辑。
解决方案
推荐阅读
- nativescript - NativeScript 动画模态页面
- c# - 位置 (-1) 处没有行 - 尝试保存 DataTable 更改时的 SQL Server
- javascript - 尽管 promise 评估为 false,但函数返回 true
- android-studio - Android Studio 传递数据
- listview - Flutter:防止边缘削波
- php - 如何组织这个上下文?两张桌子还是一张?
- git - 合并两个分支,如何为所有冲突接受一个分支
- javascript - 无法同时延迟我网站上的视频和图像。
- c++ - 避免非类类型的指向成员函数的指针
- vb.net - 在流中的图像控件中显示图片