Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter web Include autocomplete

I have created a login form in flutter web, when I login, chrome detects the password that was entered, but offers only to save the password, while the username stays blank.

Google suggests the following HTML form so that credential manager can detect the credentials that needs to be stored.

<form id="signup" method="post">
 <input name="email" type="text" autocomplete="username email">
 <input name="display-name" type="text" autocomplete="name">
 <input name="password" type="password" autocomplete="new-password">
 <input type="submit" value="Sign Up!">
</form>

In my form I used both email and username but chrome credential manager is still not able to detect the username.

How can we create the form with autocomplete tag in flutter web?

like image 380
max Avatar asked Mar 07 '20 09:03

max


1 Answers

Flutter supports now autofill (password, email, username, etc.) ☑️ The merged pull request with an example: https://github.com/flutter/flutter/pull/52126

Example:

 @override
  Widget build(BuildContext context) {
    return AutofillGroup(
      child: Column(
        children: <Widget>[
          TextField(controller: username, autofillHints: [AutofillHints.username]),
          Checkbox(
            value: isNewUser,
            onChanged: (bool newValue) {
              setState(() { isNewUser = newValue; });
            },
          ),
          if (isNewUser) TextField(controller: newPassword, autofillHints: [AutofillHints.newPassword]),
          if (isNewUser) TextField(controller: repeatNewPassword, autofillHints: [AutofillHints.newPassword]),
          if (!isNewUser) TextField(controller: password, autofillHints: [AutofillHints.password]),
        ],
      ),
    );
  }

You may need to switch to dev or master channel (flutter channel master).

like image 156
Nils Reichardt Avatar answered Nov 13 '22 04:11

Nils Reichardt