title: Disabled button when textInputField is invalid on change text Flutter
body: <p>I'm new on Flutter.
  I'm trying to disabled button while I compile textFormField and it is invalid.
  My problem is that it works only if I click on "confirm" on keyboard and not <em>while</em> I compile my input.
  So would like disable button while I write the input.</p>
  
  <p>I've done a pastebin for example:</p>
  
  <p><a href="https://pastebin.com/q5WuwrCm" rel="nofollow noreferrer">https://pastebin.com/q5WuwrCm</a></p>
  
  <pre><code>class AddCartButton extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() {
      return AddCartButtonState();
    }
  }
  class AddCartButtonState extends State&lt;AddCartButton&gt;{
    TextEditingController myController = TextEditingController();
    bool isValid = false;
    @override
    Widget build(BuildContext context) {
      void _addToCart(){
        showDialog(
          context: context,
          builder: (BuildContext context) {
            return AlertDialog(
              title: Text("QUANTITY"),
              content: Column(
                children: &lt;Widget&gt;[
                  TextFormField(
                      controller: myController,
                      decoration: new InputDecoration(labelText: "quantity"),
                      keyboardType: TextInputType.numberWithOptions(decimal: true),
                      inputFormatters: &lt;TextInputFormatter&gt;[],
                      autovalidate: true,
                      validator: (value) {
                        if (value.isEmpty) {
                          isValid  = false;
                          return "the quantity cannot be empty";
                        } else if (double.tryParse(value) == null) {
                          isValid = false;
                          return "the quantity must be valid number";
                        } else {
                          isValid = true;
                          return null;
                        }
                      }
                  )
                ],
              ),
              actions: &lt;Widget&gt;[
                FlatButton(
                    disabledTextColor: Colors.grey,
                    child: Text("add"),
                    onPressed: isValid ? () { print("is valid"); }: null
                )
              ],
            );
          },
        );
      }
    }
  }        
  </code></pre>