Nirav Bhavsar
Nirav Bhavsar

Reputation: 2233

Flutter - How to restart or redraw current screen Widget

I'm using Navigation drawer and in it i have design one screen name as PostProperty screen in which multiple text form fields, image uploading are implemented, what i want is when user click on submit/add button, then the current screen widget should be redraw or all form fields should be clear so that user can submit/add another, please guide me, how to achieve this.

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 is the form in which i have include all text form field and other content.

Please see below screenshot

enter image description here

enter image description here

Upvotes: 0

Views: 2395

Answers (1)

amam
amam

Reputation: 43

You could change the key for each TextFormField dynamically once you submit and also change the TextEditingControllers' values to null.

Upvotes: 4

Related Questions