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 loading = false;
bool showPassword = false; bool showPassword = false;
void toggleShowPassword() => setState(() => showPassword = !showPassword); void toggleShowPassword() =>
setState(() => showPassword = !loading && !showPassword);
void login([_]) async { void login([_]) async {
final matrix = Matrix.of(context); final matrix = Matrix.of(context);

View File

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