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')),
// 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: <Widget>[
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)),
)),
),
);
}
}