From 9807db52ae88f68da4372c84a49e5fecb49d4fa4 Mon Sep 17 00:00:00 2001 From: doman Date: Sun, 30 Jul 2023 15:37:11 +0200 Subject: [PATCH] autofill should work now --- lib/screens/login.dart | 76 ++++++++++++++++++++------------------- lib/screens/register.dart | 65 +++++++++++++++++---------------- 2 files changed, 73 insertions(+), 68 deletions(-) diff --git a/lib/screens/login.dart b/lib/screens/login.dart index ae3d9b5..c798e6f 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -105,47 +105,49 @@ class _LoginScreen extends State { child: Container( constraints: const BoxConstraints(maxWidth: 600), padding: const EdgeInsets.all(10), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextFormField( - decoration: const InputDecoration( - labelText: 'Username', + child: AutofillGroup( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextFormField( + decoration: const InputDecoration( + labelText: 'Username', + ), + controller: usernameController, + autofillHints: const [AutofillHints.username], ), - controller: usernameController, - autofillHints: const [AutofillHints.username], - ), - TextFormField( - obscureText: true, - decoration: const InputDecoration( - labelText: 'Password', + TextFormField( + obscureText: true, + decoration: const InputDecoration( + labelText: 'Password', + ), + controller: passwordController, + onFieldSubmitted: (_) => _login(), + autofillHints: const [AutofillHints.password], ), - controller: passwordController, - onFieldSubmitted: (_) => _login(), - autofillHints: const [AutofillHints.password], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: FilledButton( - onPressed: _login, - child: const Text('Login'), + Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: FilledButton( + onPressed: _login, + child: const Text('Login'), + ), ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: TextButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => RegisterScreen(apiClient: widget.apiClient), - ), - ); - }, - child: const Text('Don\'t have an account? Register here!'), + Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => RegisterScreen(apiClient: widget.apiClient), + ), + ); + }, + child: const Text('Don\'t have an account? Register here!'), + ), ), - ), - ], + ], + ), ), ), ), diff --git a/lib/screens/register.dart b/lib/screens/register.dart index d762981..f1db545 100644 --- a/lib/screens/register.dart +++ b/lib/screens/register.dart @@ -90,40 +90,43 @@ class _RegisterScreen extends State { child: Container( constraints: const BoxConstraints(maxWidth: 600), padding: const EdgeInsets.all(10), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextFormField( - decoration: const InputDecoration( - labelText: 'Username', + child: AutofillGroup( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextFormField( + decoration: const InputDecoration( + labelText: 'Username', + ), + controller: usernameController, + autofillHints: const [AutofillHints.username], ), - controller: usernameController, - autofillHints: const [AutofillHints.username], - ), - TextFormField( - obscureText: true, - decoration: const InputDecoration( - labelText: 'Password', + TextFormField( + obscureText: true, + decoration: const InputDecoration( + labelText: 'Password', + ), + controller: passwordController, + autofillHints: const [AutofillHints.password], ), - controller: passwordController, - autofillHints: const [AutofillHints.password], - ), - TextFormField( - obscureText: true, - decoration: const InputDecoration( - labelText: 'Confirm password', + TextFormField( + obscureText: true, + decoration: const InputDecoration( + labelText: 'Confirm password', + ), + controller: passwordConfirmController, + autofillHints: const [AutofillHints.password], + onFieldSubmitted: (_) => _register() ), - controller: passwordConfirmController, - onFieldSubmitted: (_) => _register() - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: FilledButton( - onPressed: _register, - child: const Text('Register'), - ) - ), - ], + Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: FilledButton( + onPressed: _register, + child: const Text('Register'), + ) + ), + ], + ), ), ), ),