alb*_*123 4 authentication autofill flutter
我发现了几个与此类似的问题,但没有任何效果。我可能没有掌握自动填充功能的基础知识。
我正在 iPhone 11 Pro(物理设备)上测试我的代码。我希望它也能在 Android 上运行,但我目前没有任何物理设备可以测试,只有模拟器。
我有一个简单的登录表单,其中包含电子邮件和密码字段:
TextFormField(keyboardType: TextInputType.emailAddress,
autofillHints: [AutofillHints.email],
textInputAction: TextInputAction.next),
TextFormField(obscureText: true,
autofillHints: [AutofillHints.password],
onEditingComplete: () => TextInput.finishAutofillContext()),
Run Code Online (Sandbox Code Playgroud)
插入数据后,我将它们保存在两个变量(_email和_password)中,当按下提交按钮时,我用 来检查它们FirebaseAuth。登录过程工作正常。
我想保存这些凭据并在以下登录时记住它们。我将它们保存在 上secure_storage,因为我在某处读到这将它们保存在 iOS 钥匙串上...但没有执行任何操作。
当我提交表单时,系统不会要求我保存凭据。当我单击填充字段时,键盘建议我打开“密码”,但没有与我的应用程序相关的实例。
我读了一些主题,但我不明白我应该做什么。看起来它应该自动工作,但事实并非如此。
我需要检查一些设置吗?我需要导入一些库吗?
请尽可能清楚地说明,这是我的第一个 Flutter 应用程序。谢谢。
将您的 TextFormFields 包装起来,AutofillGroup让用户使用密码管理器保存它们。
AutofillGroup(
child: Column(
children: <Widget>[
TextFormField(
keyboardType: TextInputType.emailAddress,
autofillHints: [AutofillHints.email],
textInputAction: TextInputAction.next,
),
TextFormField(
obscureText: true,
autofillHints: [AutofillHints.password],
onEditingComplete: () =>
TextInput.finishAutofillContext(),
),
],
),
),
Run Code Online (Sandbox Code Playgroud)
如果您希望应用程序处理自动填充,您需要从中获取凭据secure_storage并将值插入表单中。
| 归档时间: |
|
| 查看次数: |
6014 次 |
| 最近记录: |