handle changes of form fields in flutter

How to disable submit button unless forms form fields are edited/changed in flutter dart?
I’m able to disable the submit button when form fields are empty but i want to disable it when they are edited

1 thought on “handle changes of form fields in flutter”

  1. For this king operation use Stream or any state management solutions. this is just a basic example. I hope this may help you.

        var textValue = "";
    
    
    
    
        TextFormField(
                onChanged :(v){
                 textValue =  v;
                  setState((){});
               })
    
    
    RaisedButton(
          onPressed: textValue.isEmpty
                     ? null
                      : () {
                            // do something
                       },
                    child: Text("Button"),
                      )
    

    Button will be disabled onPressed has null or not implemented!

    Reply

Leave a Comment