dart - Flutter - 如何重启或重绘当前屏幕小部件
问题描述
我正在使用导航抽屉,在其中我设计了一个屏幕名称作为 PostProperty 屏幕,其中实现了多个文本表单字段,图像上传,我想要的是当用户单击提交/添加按钮时,当前屏幕小部件应该是重绘或所有表单字段应该清楚,以便用户可以提交/添加另一个,请指导我,如何实现这一点。
小部件构建代码
@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是我包含所有文本表单字段和其他内容的表单。
请看下面的截图
解决方案
提交后,您可以动态更改每个 TextFormField 的键,并将 TextEditingControllers 的值更改为 null。
推荐阅读
- javascript - d3.js堆积条形图——修改堆积顺序逻辑
- python - 如何从“https://www.nseindia.com/companies-listing/corporate-filings-event-calendar?days=7days”中抓取数据
- javascript - 有没有办法从 html 的画布中提取原点坐标?
- opencv - 有什么方法可以从完整视频中检测和剪切出真实的视频部分
- c# - Prism InvokeCommandAction 可以与 Microsoft.Xaml.Behaviors.Wpf 一起使用吗
- antlr4 - ANTLR 将可选标签优先于非可选标签
- python - Python Post Request 为以下 post 请求返回 422 错误
- php - Symfony / API 平台 - 多对多关系仅以一种方式工作
- r - 将行映射到 R 中的列列表
- sql - 错误:数字类型的输入语法无效:“”