title: Show/Hide Passwords in Flutter's TextFormField
body: <p>I'm working on a TextFormField to accept passwords. I have set the suffix icon to have IconButton child to detect on click events and to toggle the obscuretext attribute of the TextFormField. The callback function for the iconButton gets called but the TextFormField doesn't get repainted. Any ideas on how to solve this?</p>
  
  <pre><code>static Widget buildTextFormField(String id, 
                                 FormFieldValidator&lt;String&gt; validateField,
                                 FormFieldSetter&lt;String&gt; saveField,
                                 InputDecoration decoration,
                                 EdgeInsetsGeometry paddingInfo,
                                 EdgeInsetsGeometry marginInfo,
                                 TextInputType keyboardType,
                                 {bool obscureField:false, double width:328.0,
                                  TextEditingController controller}
    ){
  return Container(
    padding: paddingInfo,
    margin: marginInfo,
    width: width,
    child: TextFormField(
      key: Key(id),
      obscureText: obscureField,
      validator: validateField,
      onSaved: saveField,
      keyboardType: keyboardType,
      decoration: decoration,
      controller: controller,
    ),
  );
  </code></pre>
  
  <p>}</p>
  
  <pre><code>InputDecoration passwordDecoration = InputDecoration(
     hintText: 'Password',
     labelText: 'Enter your password',
     suffixIcon:
        IconButton(
           icon: Icon(
              _passwordVisible ? Icons.visibility : Icons.visibility_off,
              semanticLabel: _passwordVisible ? 'hide password' : 'show password',
           ),
           onPressed: () {
              setState(() {
                 _passwordVisible ^= true;
                 //print("Icon button pressed! state: $_passwordVisible"); //Confirmed that the _passwordVisible is toggled each time the button is pressed.
              });
           }),
     labelStyle: TextStyle(
        fontFamily: 'Roboto Medium',
        fontSize: 12.0,
        color: Color(0x99000000),
        letterSpacing: 0.4,
     ),
  );
  final passwordPaddingInfo = const EdgeInsets.only(top: 15.0, bottom:15.0,
                                                    left: 22.0, right:25.0);
  this._passwordField = AdministrationComponents.
  buildTextFormField('passwordField', validatePassword,
     (value) =&gt; _password = value, passwordDecoration, passwordPaddingInfo,
     null, null, controller:_passwordController,
     obscureField: !_passwordVisible);
  </code></pre>