username field

This commit is contained in:
Specoolazius 2021-11-15 13:26:13 +01:00
parent aaaada1b23
commit 807d2a87cd

View File

@ -29,27 +29,49 @@ class _LoginPageState extends State<LoginPage> {
appBar: AppBar(title: const Text('Welcome')), appBar: AppBar(title: const Text('Welcome')),
// https://www.kindacode.com/article/flutter-show-hide-password-in-textfield-textformfield/ // https://www.kindacode.com/article/flutter-show-hide-password-in-textfield-textformfield/
// https://www.kindacode.com/article/flutter-filteringtextinputformatter/ // https://www.kindacode.com/article/flutter-filteringtextinputformatter/
body: Padding( body: ListView(
padding: const EdgeInsets.all(10), children: <Widget>[
child: Center( UsernameField(),
child: TextField( Padding(
obscureText: _isPasswordObscure, padding: const EdgeInsets.all(10),
decoration: InputDecoration( child: Center(
hintText: 'Password', child: TextField(
border: OutlineInputBorder( obscureText: _isPasswordObscure,
borderRadius: BorderRadius.circular(10) decoration: InputDecoration(
), hintText: 'Password',
suffixIcon: IconButton( border: OutlineInputBorder(
icon: Icon(_isPasswordObscure borderRadius: BorderRadius.circular(10)),
? Icons.visibility suffixIcon: IconButton(
: Icons.visibility_off), icon: Icon(_isPasswordObscure
onPressed: () { ? Icons.visibility
setState(() { : Icons.visibility_off),
_isPasswordObscure = !_isPasswordObscure; 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)),
)),
),
);
}
}