Tomasz Michlewski
Tomasz Michlewski

Reputation: 73

Flutter autofillHints reveal password

the problem is as follows.

I implemented autofill to log-in fields. The function works very well on android and iOS. It turned out, however, that the password hint on a Pixel 4 phone isn't obscure. Does anyone know how to fix this?

[Pixel 4 screenshot][1]

Update, code below:

AutofillGroup(
    child: Column(
      children: [
        TextFormField(
          autofillHints: [widget.signUpMode ? AutofillHints.newUsername : AutofillHints.username],
          keyboardType: TextInputType.emailAddress,
          autovalidateMode: AutovalidateMode.onUserInteraction,
          validator: (String? value) {
            if (value!.isEmpty) {
              return S.of(context).formFieldValueRequiredLabel;
            }
            return null;
          },
        ),
        const SizedBox(height: 12),
        if (widget.passwordController != null) ...[
          TextFormField(
            focusNode: passwordFocusNode,
            autofillHints: [widget.signUpMode ? AutofillHints.newPassword : AutofillHints.password],
            controller: widget.passwordController,
            maxLength: 60,
            obscureText: obscureText,
            textAlign: TextAlign.center,
            decoration: AppTheme.formFieldDecoration(),
            style: AppTheme.formFieldStyleText,
            keyboardType: TextInputType.text,
            autovalidateMode: AutovalidateMode.onUserInteraction,
            validator: (String? value) {
              if (value!.isEmpty) {
                return S.of(context).formFieldValueRequiredLabel;
              }
              return null;
            },
          )
        ],
      ],
    ),
  )

Upvotes: 1

Views: 835

Answers (1)

Jashwanth Neela
Jashwanth Neela

Reputation: 463

Did you tried disabling the suggestions to Text Form Field like below

TextFormField(
        obscureText: true,
        enableSuggestions: false, // add this line
        )

Upvotes: 2

Related Questions