Samreaksa Ros

Web Developer - iOS Developer

Validation Form – Flutter

Please feel to use this code template for your flutter project. It is very useful and saves time for developing your mobile application plan. Please contact me by skype: samreaksa.skype if you have problems with your flutter Validation Form – Flutter.

Widget _showPasswordInput() {
    return Padding(
              padding: EdgeInsets.only(top: 20.0),
              child: TextFormField(
                onSaved: (val) => _password = val,
                obscureText: _obscureText,
                validator: (val) => val.length < 8 ? 'Password too short' : null,
                decoration: InputDecoration(
                  suffixIcon: GestureDetector(
                    onTap: () {
                      setState(() {
                       _obscureText = !_obscureText; 
                      });
                    },
                    child: Icon(
                      _obscureText ? Icons.visibility : Icons.visibility_off
                    ),
                  ),
                  
                  border: OutlineInputBorder(),
                  labelText: 'Password',
                  hintText: 'Enter password, min length 6',
                  icon: Icon(Icons.lock, color: Colors.grey))
                )
            );
  }
  void _submit() {
   // if (_formkey.currentState.validate()) {
    //   print('form valid');
    // }else{
    //   print('form invalid');
    // }
    final form = _formkey.currentState;
    if(form.validate()) {
      form.save();
      print('Email: $_email, Password: $_password');
    }
  }