Question : show password in flutter
Answered by : charming-cardinal-ue74l6xbz2lc
TextFormField( keyboardType: TextInputType.text, controller: _userPasswordController, obscureText: !_passwordVisible,//This will obscure text dynamically decoration: InputDecoration( labelText: 'Password', hintText: 'Enter your password', // Here is key idea suffixIcon: IconButton( icon: Icon( // Based on passwordVisible state choose the icon _passwordVisible ? Icons.visibility : Icons.visibility_off, color: Theme.of(context).primaryColorDark, ), onPressed: () { // Update the state i.e. toogle the state of passwordVisible variable setState(() { _passwordVisible = !_passwordVisible; }); }, ), ), );
Source : https://stackoverflow.com/questions/49125064/how-to-show-hide-password-in-textformfield | Last Update : Mon, 17 May 21
Question : password validation in flutter
Answered by : you
String validatePassword(String value) { // Password should have at least 6 characters if (value.length < 6) { return 'Password must contain at least 6 characters'; } // Password should have at least one uppercase letter if (!value.contains(RegExp(r'[A-Z]'))) { return 'Password must contain at least one uppercase letter'; } // Password should have at least one lowercase letter if (!value.contains(RegExp(r'[a-z]'))) { return 'Password must contain at least one lowercase letter'; } // Password should have at least one digit if (!value.contains(RegExp(r'[0-9]'))) { return 'Password must contain at least one digit'; } // Password is valid return null;
}
Source : | Last Update : Mon, 18 Sep 23
Question : how to validate confirm password in flutter
Answered by : helpful-hamerkop-c1s49se52r29
// Form final GlobalKey<FormState> _form = GlobalKey<FormState>(); final TextEditingController _pass = TextEditingController(); final TextEditingController _confirmPass = TextEditingController(); Form( key: _form, child: ListView( children: <Widget>[ TextFormField( controller: _pass, validator: (val){ if(val.isEmpty) return 'Empty'; return null; } ), TextFormField( controller: _confirmPass, validator: (val){ if(val.isEmpty) return 'Empty'; if(val != _pass.text) return 'Not Match' return null; } ), ] ) ) // To validate call _form.currentState.validate()
Source : https://stackoverflow.com/questions/58444330/how-to-match-password-and-confirm-password-in-flutter | Last Update : Wed, 27 Apr 22
Question : show password in flutter
Answered by : charming-cardinal-ue74l6xbz2lc
@override void initState() { _passwordVisible = false; }
Source : https://stackoverflow.com/questions/49125064/how-to-show-hide-password-in-textformfield | Last Update : Mon, 17 May 21