Getting started with 1Password for your growing team, or refining your setup? Our Secured Success quickstart guide is for you.
Forum Discussion
seankang
13 days agoNew Contributor
flutter login example
Hello
I am building a flutter app that integrates with AWS cognito.
In my custom Login Screen, I use flutter TextFormField and specify :
TextFormField(....
autofillHints: const [AutofillHints.username],
...)
TextFormField(...
autofillHints: const [AutofillHints.password],
...),
)
However, when the focus is on just the password, and the 1password prompt appears to suggest an auto-fill, it will only autofill the item that has the focus, not both username and password.
How do I get 1password to auto-fill both username and password from one action?
Right now, I have to change the focus on each field, and have 1password auto-fill those fields individually.
5 Replies
- seankangNew Contributor
Now my next follow up question is this:
My mobile app has a corresponding website.
How does the flutter app which can be deployed as a website and mobile app tie itself together so that 1password knows the 1 credential works for both the mobile app and the website?
- 1P_Phil
Moderator
Hi seankang ,
Let me try to restate the question:
- you have a website hosting your app : http://www.website.com/app (or something like that)
- you are working on an app : com.website.appNameMy understanding is that the URI for both is used in looking up the password in the Vault. Some applications/sites have a similar fundamental domain like "www.website.com" and "com.website.app" (just reversed). Other apps/websites have login services that have completely different.
In the case of a different service, the user just has to manually look up the password and then they will be presented with the option to save or update the password.
I don't see any content about how to make these work best, but typically if you follow these guidelines (link below) and a similar URI structure it should work. Now if you are looking at doing PassKeys there is a bit more configuration on the Apple & Android side (they have lots of docs for this).
https://developer.1password.com/docs/web/compatible-website-design (Web)
https://blog.1password.com/what-is-webauthn (Passkeys)Let me know if this helps.
Cheers,
Phil
- seankangNew Contributor
You're right --
I also searched it on chatgpt.
I have to use a parent object called AutofillGroup
```
class LoginScreen extends StatelessWidget {
final emailCtrl = TextEditingController();
final pwCtrl = TextEditingController();
final otpCtrl = TextEditingController();LoginScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Sign in')),
body: Padding(
padding: const EdgeInsets.all(16),
child: AutofillGroup(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextFormField(
controller: emailCtrl,
keyboardType: TextInputType.emailAddress,
textInputAction: TextInputAction.next,
autofillHints: const [AutofillHints.username, AutofillHints.email],
decoration: const InputDecoration(labelText: 'Email'),
autocorrect: false,
textCapitalization: TextCapitalization.none,
),
const SizedBox(height: 12),
TextFormField(
controller: pwCtrl,
obscureText: true,
textInputAction: TextInputAction.done,
autofillHints: const [AutofillHints.password],
decoration: const InputDecoration(
labelText: 'Password',
suffixIcon: Icon(Icons.key_outlined), // add your show/hide logic
),
onEditingComplete: () => TextInput.finishAutofillContext(),
),
const SizedBox(height: 12),
TextFormField(
controller: otpCtrl,
keyboardType: TextInputType.number,
autofillHints: const [AutofillHints.oneTimeCode],
decoration: const InputDecoration(labelText: '6-digit code'),
),
const SizedBox(height: 20),
FilledButton(
onPressed: () async {
// 1) Your password login flow
// 2) After success:
TextInput.finishAutofillContext();
},
child: const Text('Sign in'),
),
const SizedBox(height: 12),
OutlinedButton.icon(
icon: const Icon(Icons.fingerprint),
label: const Text('Sign in with a passkey'),
onPressed: () async {
// Call your server to get WebAuthn "get" options then use `passkeys.get(...)`
},
),
],
),
),
),
);
}
}```