Home > Blockchain >  Flutter prevent editing input while on submit
Flutter prevent editing input while on submit

Time:07-28

I would like to know if its possible to disable the TextFormField while the data that was input is being submitted? This is to prevent editing the input while its submitting.

CodePudding user response:

You can achieve this by several ways using ignore pointer or TextForField's own property readOnly

  1. Declare a variable on top of the class like below:

    bool submitted = false;
    
  2. Set your variable value to true while submitting your form.

    InkWell(
     onTap:(){
      setState((){
        submitted = true;
       });
      }
     child:Text("Submitted")
    );
    
  3. Assign that value to your TextFormField or TextField like below:

    TextFormField(
     readOnly: submitted, //if true it will not allow user to edit else it will allow user to edit
     ...
    )
    

CodePudding user response:

Just create a loading animation to overlay the form while submitting

  • Related