Flutter Web:在 TextFormField 中未触发自动填充密码建议

问题描述 投票:0回答:2

我正在尝试使用 Google 密码管理器自动填充电子邮件和密码。这似乎适用于 Android,但不适用于 Web。

示例:

Form(
    key: key,
    child: AutofillGroup(
      child: Column(
        children: [
          TextFormField(
            autofillHints: const [AutofillHints.email],
            keyboardType: TextInputType.emailAddress,
            textInputAction: TextInputAction.next,
          ),
          TextFormField(autofillHints: const [AutofillHints.password],),
          ElevatedButton(
            onPressed: (){
              TextInput.finishAutofillContext();
              Navigator.of(context).pushReplacementNamed('/home');
            },
            child: const Text('Login'),
          ),
        ],
      ),
    ),
  ),

当我按下“登录”按钮时,浏览器(Google Chrome)会显示一个弹出窗口,允许我使用密码管理器保存电子邮件和密码,然后转到主屏幕。

问题是当我尝试再次登录时:电子邮件和密码已保存,但它们不会自动填充,或者当我单击任何字段时甚至不会显示为建议。 Pop-up

注意:我已经链接了google账户并开启了同步。

截图:Common website with autofill and suggestions behavior 这在我的应用程序中不起作用。

flutter autocomplete flutter-web autofill password-manager
2个回答
4
投票

GitHub 上有人已经在 Flutter 存储库上提交了此问题(无自动填充建议)

问题在 Flutter 官方存储库中处于 Open 状态。您可以在此处

查看相关更新

希望有帮助。


0
投票

在文本字段中使用

AutofillGroup
autofillHints
有效。您可以通过flutter Campus在这里找到代码。

AutofillGroup(
  child:Column(
    children: [
        TextField(
            autofillHints: [AutofillHints.username],
            decoration: InputDecoration(
              hintText: "Username"
            ),
        ),

        TextField(
            obscureText: true,
            autofillHints: [AutofillHints.password],
            decoration: InputDecoration(
              hintText: "Password"
            ),
        ),
    ],
  )
)
© www.soinside.com 2019 - 2024. All rights reserved.