Answers for "Form Field flutter"

3

flutter form

final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Form(
      key: _formKey,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          TextFormField(
            decoration: const InputDecoration(
              hintText: 'Enter your email',
            ),
          ),
          ElevatedButton(
            onPressed: () {  },
            child: const Text('Submit'),
          ),
        ],
      ),
    ),
Posted by: Guest on August-30-2021
2

validator flutter

final passwordValidator = MultiValidator([  
    RequiredValidator(errorText: 'password is required'),  
    MinLengthValidator(8, errorText: 'password must be at least 8 digits long'),  
    PatternValidator(r'(?=.*?[#?!@$%^&*-])', errorText: 'passwords must have at least one special character')  
 ]);  
  
  String password;  
  
  Form(  
    key: _formKey,  
    child: Column(children: [  
      TextFormField(  
        obscureText: true,  
        onChanged: (val) => password = val,  
        // assign the the multi validator to the TextFormField validator  
        validator: passwordValidator,  
      ),  
  
      // using the match validator to confirm password  
      TextFormField(  
        validator: (val) => MatchValidator(errorText: 'passwords do not match').validateMatch(val, password),  
      )  
    ]),  
  );
Posted by: Guest on October-08-2020

Code answers related to "Form Field flutter"

Code answers related to "Dart"

Browse Popular Code Answers by Language