Flutter web Include autocomplete

3,734

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).

Share:
3,734
max
Author by

max

Updated on December 18, 2022

Comments

  • max
    max over 1 year

    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?