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);
},
),
),
);
}
@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