autofill should work now

This commit is contained in:
doman 2023-07-30 15:37:11 +02:00
parent 64703dbc67
commit 9807db52ae
2 changed files with 73 additions and 68 deletions

View file

@ -105,47 +105,49 @@ class _LoginScreen extends State<LoginScreen> {
child: Container( child: Container(
constraints: const BoxConstraints(maxWidth: 600), constraints: const BoxConstraints(maxWidth: 600),
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Column( child: AutofillGroup(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: <Widget>[ mainAxisAlignment: MainAxisAlignment.center,
TextFormField( children: <Widget>[
decoration: const InputDecoration( TextFormField(
labelText: 'Username', decoration: const InputDecoration(
labelText: 'Username',
),
controller: usernameController,
autofillHints: const [AutofillHints.username],
), ),
controller: usernameController, TextFormField(
autofillHints: const [AutofillHints.username], obscureText: true,
), decoration: const InputDecoration(
TextFormField( labelText: 'Password',
obscureText: true, ),
decoration: const InputDecoration( controller: passwordController,
labelText: 'Password', onFieldSubmitted: (_) => _login(),
autofillHints: const [AutofillHints.password],
), ),
controller: passwordController, Padding(
onFieldSubmitted: (_) => _login(), padding: const EdgeInsets.symmetric(vertical: 10),
autofillHints: const [AutofillHints.password], child: FilledButton(
), onPressed: _login,
Padding( child: const Text('Login'),
padding: const EdgeInsets.symmetric(vertical: 10), ),
child: FilledButton(
onPressed: _login,
child: const Text('Login'),
), ),
), Padding(
Padding( padding: const EdgeInsets.symmetric(vertical: 10),
padding: const EdgeInsets.symmetric(vertical: 10), child: TextButton(
child: TextButton( onPressed: () {
onPressed: () { Navigator.push(
Navigator.push( context,
context, MaterialPageRoute(
MaterialPageRoute( builder: (context) => RegisterScreen(apiClient: widget.apiClient),
builder: (context) => RegisterScreen(apiClient: widget.apiClient), ),
), );
); },
}, child: const Text('Don\'t have an account? Register here!'),
child: const Text('Don\'t have an account? Register here!'), ),
), ),
), ],
], ),
), ),
), ),
), ),

View file

@ -90,40 +90,43 @@ class _RegisterScreen extends State<RegisterScreen> {
child: Container( child: Container(
constraints: const BoxConstraints(maxWidth: 600), constraints: const BoxConstraints(maxWidth: 600),
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
child: Column( child: AutofillGroup(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: <Widget>[ mainAxisAlignment: MainAxisAlignment.center,
TextFormField( children: <Widget>[
decoration: const InputDecoration( TextFormField(
labelText: 'Username', decoration: const InputDecoration(
labelText: 'Username',
),
controller: usernameController,
autofillHints: const [AutofillHints.username],
), ),
controller: usernameController, TextFormField(
autofillHints: const [AutofillHints.username], obscureText: true,
), decoration: const InputDecoration(
TextFormField( labelText: 'Password',
obscureText: true, ),
decoration: const InputDecoration( controller: passwordController,
labelText: 'Password', autofillHints: const [AutofillHints.password],
), ),
controller: passwordController, TextFormField(
autofillHints: const [AutofillHints.password], obscureText: true,
), decoration: const InputDecoration(
TextFormField( labelText: 'Confirm password',
obscureText: true, ),
decoration: const InputDecoration( controller: passwordConfirmController,
labelText: 'Confirm password', autofillHints: const [AutofillHints.password],
onFieldSubmitted: (_) => _register()
), ),
controller: passwordConfirmController, Padding(
onFieldSubmitted: (_) => _register() padding: const EdgeInsets.symmetric(vertical: 10),
), child: FilledButton(
Padding( onPressed: _register,
padding: const EdgeInsets.symmetric(vertical: 10), child: const Text('Register'),
child: FilledButton( )
onPressed: _register, ),
child: const Text('Register'), ],
) ),
),
],
), ),
), ),
), ),