I want to add eye to password field in flutter project
this is my code:
TextFormField(
decoration: const InputDecoration(
label: Text('PASSWORD'),
),
keyboardType: TextInputType.visiblePassword,
obscureText: true,
validator: (val) {
if (val!.length < 6) {
return "Please enter at least 6 characters";
}
return null;
},
onSaved: (val) => data['password'] = val!,
),
3
Answers
Add a suffixIcon in the decoration part :
You can use this custom widget:
and use it like this:
Create a boolean variable which will hold the status of password of being shown or not.
bool hidePassword=true;
Now, add this
TextFormField
withobscureText
property.