From 23a27fde6751831cfbc6d24f5d8ac0fa029f8754 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 10 May 2022 23:42:27 +1000 Subject: [PATCH] Adds ability to show / hide password in profile widget --- lib/settings/login.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/settings/login.dart b/lib/settings/login.dart index 5c29e162..a998af41 100644 --- a/lib/settings/login.dart +++ b/lib/settings/login.dart @@ -240,6 +240,8 @@ class _ProfileEditState extends State { String username = ""; String password = ""; + bool _obscured = true; + @override Widget build(BuildContext context) { return Scaffold( @@ -379,10 +381,18 @@ class _ProfileEditState extends State { labelText: L10().password, labelStyle: TextStyle(fontWeight: FontWeight.bold), hintText: L10().enterPassword, + suffixIcon: IconButton( + icon: _obscured ? FaIcon(FontAwesomeIcons.eye) : FaIcon(FontAwesomeIcons.solidEyeSlash), + onPressed: () { + setState(() { + _obscured = !_obscured; + }); + }, + ), ), initialValue: profile?.password ?? "", keyboardType: TextInputType.visiblePassword, - obscureText: true, + obscureText: _obscured, onSaved: (value) { password = value ?? ""; },