From 807d2a87cd8e4864e14b1a10a533a4280365fffc Mon Sep 17 00:00:00 2001 From: Specoolazius Date: Mon, 15 Nov 2021 13:26:13 +0100 Subject: [PATCH] username field --- lib/login/loginscreen.dart | 64 +++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/lib/login/loginscreen.dart b/lib/login/loginscreen.dart index a6a36cb..40c7183 100644 --- a/lib/login/loginscreen.dart +++ b/lib/login/loginscreen.dart @@ -29,27 +29,49 @@ class _LoginPageState extends State { appBar: AppBar(title: const Text('Welcome')), // https://www.kindacode.com/article/flutter-show-hide-password-in-textfield-textformfield/ // https://www.kindacode.com/article/flutter-filteringtextinputformatter/ - body: Padding( - padding: const EdgeInsets.all(10), - child: Center( - child: TextField( - obscureText: _isPasswordObscure, - decoration: InputDecoration( - hintText: 'Password', - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10) - ), - suffixIcon: IconButton( - icon: Icon(_isPasswordObscure - ? Icons.visibility - : Icons.visibility_off), - onPressed: () { - setState(() { - _isPasswordObscure = !_isPasswordObscure; - }); - }, - ))), - ), + body: ListView( + children: [ + UsernameField(), + Padding( + padding: const EdgeInsets.all(10), + child: Center( + child: TextField( + obscureText: _isPasswordObscure, + decoration: InputDecoration( + hintText: 'Password', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10)), + suffixIcon: IconButton( + icon: Icon(_isPasswordObscure + ? Icons.visibility + : Icons.visibility_off), + onPressed: () { + setState(() { + _isPasswordObscure = !_isPasswordObscure; + }); + }, + ))), + ), + ) + ], )); } } + +class UsernameField extends StatelessWidget { + const UsernameField({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(10), + child: Center( + child: TextField( + decoration: InputDecoration( + hintText: 'Username', + border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)), + )), + ), + ); + } +}