Reputation: 353
we're currently developing a Flutter app (Dart language).
There is a Login Screen with two TextField's.
The password field has
obscureText: true,
as property, which hides any input.
Password Manager
More and more people are using password manager like 1password.
How can we enable this feature in flutter?
Like this:
Currently the popup doesn't show. Nothing found on the official docs, maybe there is a google documentation about it in general?
Thanks for any help!!
Upvotes: 16
Views: 7784
Reputation: 840
Wrap your TextField
s with a AutofillGroup
widget, then mark your TextField
s with appropriate AutofillHint
s as in the example code below. Then Google's Autofill framework will show suggestions for filling both email and password automatically.
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
autofillHints: [AutofillHints.email],
hintText: "Email address",
),
const SizedBox(
height: 16,
),
TextField(
hintText: "Password",
autofillHints: [AutofillHints.password, AutofillHints.newPassword],
),
]
)));
The screenshot below shows the result:
Upvotes: 4
Reputation: 6144
I'm having similar problem in a flutter web app.
Turns out some modern browsers (chromium Firefox) do not autofill saved passwords inside a shadow-root
.
The only workaround I've found so far is to force your app to not use shadow-root
by editing embedder.dart
1 at _createHostNode
function to not use shadow-root
1 mine was found at: ~/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/lib/_engine/engine/embedder.dart
my build server - using cirrusci/flutter
docker image had it at /sdks/flutter/bin/cache/flutter_web_sdk/flutter_web_sdk/lib/_engine/engine/embedder.dart
Upvotes: 1
Reputation: 78
Check out the platform_inputs package: https://pub.dev/packages/platform_inputs
Their code sample seems to match your problem, it shows how when a textfield's textContentType
is set to TextContentType.password
with this package it will show the native password message.
Upvotes: 2