fix: Password not obscure for a second when submitting login textfield

This commit is contained in:
Christian Pauly 2022-11-13 12:01:11 +01:00
parent 1c0a17056f
commit 38d65ba3ed
2 changed files with 6 additions and 5 deletions

View File

@ -27,7 +27,8 @@ class LoginController extends State<Login> {
bool loading = false;
bool showPassword = false;
void toggleShowPassword() => setState(() => showPassword = !showPassword);
void toggleShowPassword() =>
setState(() => showPassword = !loading && !showPassword);
void login([_]) async {
final matrix = Matrix.of(context);

View File

@ -58,16 +58,16 @@ class LoginView extends StatelessWidget {
autofillHints:
controller.loading ? null : [AutofillHints.password],
controller: controller.passwordController,
textInputAction: TextInputAction.next,
textInputAction: TextInputAction.go,
obscureText: !controller.showPassword,
onSubmitted: controller.login,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock_outlined),
errorText: controller.passwordError,
errorStyle: const TextStyle(color: Colors.orange),
suffixIcon: InkWell(
onTap: controller.toggleShowPassword,
child: Icon(
suffixIcon: IconButton(
onPressed: controller.toggleShowPassword,
icon: Icon(
controller.showPassword
? Icons.visibility_off_outlined
: Icons.visibility_outlined,