Skip to content

Commit 577340c

Browse files
committed
login: Let autofill populate email and password together
This should allow using a password manager to autofill an email and password together in a single interaction. Before, in my testing, it was only autofilling the password field. Tested by Chris on iOS and by Greg on Android. Fixes-partly: zulip#35
1 parent e87fcba commit 577340c

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

lib/widgets/login.dart

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -175,27 +175,30 @@ class _EmailPasswordLoginPageState extends State<EmailPasswordLoginPage> {
175175
child: ConstrainedBox(
176176
constraints: const BoxConstraints(maxWidth: 400),
177177
child: Form(
178-
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
179-
TextFormField(
180-
key: _emailKey,
181-
keyboardType: TextInputType.emailAddress,
182-
decoration: const InputDecoration(
183-
labelText: 'Email address')),
184-
const SizedBox(height: 8),
185-
TextFormField(
186-
key: _passwordKey,
187-
obscureText: _obscurePassword,
188-
keyboardType: TextInputType.visiblePassword,
189-
decoration: InputDecoration(
190-
labelText: 'Password',
191-
suffixIcon: Semantics(label: 'Hide password', toggled: _obscurePassword,
192-
child: IconButton(
193-
onPressed: _handlePasswordVisibilityPress,
194-
icon: _obscurePassword ? const Icon(Icons.visibility_off) : const Icon(Icons.visibility))))),
195-
const SizedBox(height: 8),
196-
ElevatedButton(
197-
onPressed: _submit,
198-
child: const Text('Log in')),
199-
]))))));
178+
child: AutofillGroup(
179+
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
180+
TextFormField(
181+
key: _emailKey,
182+
autofillHints: const [AutofillHints.email],
183+
keyboardType: TextInputType.emailAddress,
184+
decoration: const InputDecoration(
185+
labelText: 'Email address')),
186+
const SizedBox(height: 8),
187+
TextFormField(
188+
key: _passwordKey,
189+
autofillHints: const [AutofillHints.password],
190+
obscureText: _obscurePassword,
191+
keyboardType: TextInputType.visiblePassword,
192+
decoration: InputDecoration(
193+
labelText: 'Password',
194+
suffixIcon: Semantics(label: 'Hide password', toggled: _obscurePassword,
195+
child: IconButton(
196+
onPressed: _handlePasswordVisibilityPress,
197+
icon: _obscurePassword ? const Icon(Icons.visibility_off) : const Icon(Icons.visibility))))),
198+
const SizedBox(height: 8),
199+
ElevatedButton(
200+
onPressed: _submit,
201+
child: const Text('Log in')),
202+
])))))));
200203
}
201204
}

0 commit comments

Comments
 (0)