@@ -202,6 +202,29 @@ class _EmailPasswordLoginPageState extends State<EmailPasswordLoginPage> {
202
202
textInputAction: TextInputAction .next,
203
203
decoration: const InputDecoration (labelText: 'Email address' ));
204
204
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
+
205
228
return Scaffold (
206
229
appBar: AppBar (title: const Text ('Log in' ),
207
230
bottom: _inProgress
@@ -218,26 +241,7 @@ class _EmailPasswordLoginPageState extends State<EmailPasswordLoginPage> {
218
241
child: Column (mainAxisAlignment: MainAxisAlignment .center, children: [
219
242
emailField,
220
243
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,
241
245
const SizedBox (height: 8 ),
242
246
ElevatedButton (
243
247
onPressed: _inProgress ? null : _submit,
0 commit comments