我正在使用抽屉导航,我在其中设计了一个屏幕名称作为 PostProperty 屏幕,其中实现了多个文本表单字段、图像上传,我想要的是当用户单击提交/添加按钮时,然后是当前屏幕应该重绘小部件或清除所有表单字段,以便用户可以提交/添加另一个,请指导我,如何实现这一点。
Widget Build Code
@override
Widget build(BuildContext context) {
return new Scaffold(
key: scaffoldKey,
resizeToAvoidBottomPadding: false,
backgroundColor: Colors.white,
appBar: showAppbar
? AppBar(
title: new Text(
setAppBarTitle(val_property_type),
style:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: ColorConstant.bg_color,
)
: null,
body: ModalProgressHUD(
inAsyncCall: _isInAsyncCall,
child: buildPropertyForm(context),
opacity: 0.5,
progressIndicator: CircularProgressIndicator(),
),
);
}
buildPropertyForm 是我在其中包含所有文本表单字段和其他内容的表单。
Please see below screenshot
最佳答案
您可以在提交后动态更改每个 TextFormField 的键,并将 TextEditingControllers 的值更改为 null。
关于dart - Flutter - 如何重启或重绘当前屏幕 Widget,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53993515/