【问题标题】:Flutter - How to restart or redraw current screen WidgetFlutter - 如何重启或重绘当前屏幕小部件
【发布时间】:2019-01-01 06:40:24
【问题描述】:

我正在使用导航抽屉,在其中我设计了一个屏幕名称作为 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 是我包含所有文本表单字段和其他内容的表单。

请看下面的截图

【问题讨论】:

    标签: dart flutter flutter-layout


    【解决方案1】:

    您可以在提交后动态更改每个 TextFormField 的键,并将 TextEditingControllers 的值更改为 null。

    【讨论】:

      猜你喜欢
      • 2018-12-09
      • 2020-01-04
      • 2011-02-05
      • 2017-10-02
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      • 2023-03-03
      • 2020-08-19
      相关资源
      最近更新 更多