Skip to content

Instantly share code, notes, and snippets.

@igabice
Created January 8, 2020 09:50
Show Gist options
  • Save igabice/0a644d794e3200bac01bbd38217f72fb to your computer and use it in GitHub Desktop.
Save igabice/0a644d794e3200bac01bbd38217f72fb to your computer and use it in GitHub Desktop.
Flutter TextField with password input type and an icon to toggle visibility
bool _showPassword = false;
Widget _buildPasswordTextField() {
return TextField(
obscureText: !this._showPassword,
decoration: InputDecoration(
labelText: 'password',
prefixIcon: Icon(Icons.security),
suffixIcon: IconButton(
icon: Icon(
Icons.remove_red_eye,
color: this._showPassword ? Colors.blue : Colors.grey,
),
onPressed: () {
setState(() => this._showPassword = !this._showPassword);
},
),
),
);
}
@AbhishekTF2020
Copy link

Nice 👍

@saiful00000
Copy link

Thanks for your help.

@rsegecin
Copy link

Thanks

@vvishnoi
Copy link

thanks

@saherla
Copy link

saherla commented Dec 8, 2020

Niceee!!

@Vishaljais004
Copy link

helpful if any one need any help comment i can help.

@Mr-Azhar
Copy link

Mr-Azhar commented Aug 1, 2021

when i enter password then TextField is set to be empty. Please help me to figure out this problem

@Vishaljais004
Copy link

Vishaljais004 commented Aug 2, 2021

when i enter password then TextField is set to be empty. Please help me to figure out this problem

i didnt get your problem can you explain briefly

@Zia-Ur-Rehman1
Copy link

great one bro thanks alot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment