Skip to content

Commit 436a3bd

Browse files
chrisbobbegnprice
authored andcommitted
login [nfc]: Pull out passwordField local, to help indentation
1 parent d0dd45f commit 436a3bd

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

lib/widgets/login.dart

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,29 @@ class _EmailPasswordLoginPageState extends State<EmailPasswordLoginPage> {
202202
textInputAction: TextInputAction.next,
203203
decoration: const InputDecoration(labelText: 'Email address'));
204204

205+
final passwordField = TextFormField(
206+
key: _passwordKey,
207+
autofillHints: const [AutofillHints.password],
208+
obscureText: _obscurePassword,
209+
keyboardType: TextInputType.visiblePassword,
210+
autovalidateMode: AutovalidateMode.onUserInteraction,
211+
validator: (value) {
212+
if (value == null || value.isEmpty) {
213+
return 'Please enter your password.';
214+
}
215+
return null;
216+
},
217+
textInputAction: TextInputAction.go,
218+
onFieldSubmitted: (value) => _submit(),
219+
decoration: InputDecoration(
220+
labelText: 'Password',
221+
suffixIcon: Semantics(label: 'Hide password', toggled: _obscurePassword,
222+
child: IconButton(
223+
onPressed: _handlePasswordVisibilityPress,
224+
icon: _obscurePassword
225+
? const Icon(Icons.visibility_off)
226+
: const Icon(Icons.visibility)))));
227+
205228
return Scaffold(
206229
appBar: AppBar(title: const Text('Log in'),
207230
bottom: _inProgress
@@ -218,26 +241,7 @@ class _EmailPasswordLoginPageState extends State<EmailPasswordLoginPage> {
218241
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
219242
emailField,
220243
const SizedBox(height: 8),
221-
TextFormField(
222-
key: _passwordKey,
223-
autofillHints: const [AutofillHints.password],
224-
obscureText: _obscurePassword,
225-
keyboardType: TextInputType.visiblePassword,
226-
autovalidateMode: AutovalidateMode.onUserInteraction,
227-
validator: (value) {
228-
if (value == null || value.isEmpty) {
229-
return 'Please enter your password.';
230-
}
231-
return null;
232-
},
233-
textInputAction: TextInputAction.go,
234-
onFieldSubmitted: (value) => _submit(),
235-
decoration: InputDecoration(
236-
labelText: 'Password',
237-
suffixIcon: Semantics(label: 'Hide password', toggled: _obscurePassword,
238-
child: IconButton(
239-
onPressed: _handlePasswordVisibilityPress,
240-
icon: _obscurePassword ? const Icon(Icons.visibility_off) : const Icon(Icons.visibility))))),
244+
passwordField,
241245
const SizedBox(height: 8),
242246
ElevatedButton(
243247
onPressed: _inProgress ? null : _submit,

0 commit comments

Comments
 (0)