centered elements
This commit is contained in:
parent
807d2a87cd
commit
3a684dd681
@ -21,40 +21,23 @@ class LoginPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LoginPageState extends State<LoginPage> {
|
class _LoginPageState extends State<LoginPage> {
|
||||||
bool _isPasswordObscure = true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
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: ListView(
|
body: Center(
|
||||||
children: <Widget>[
|
child: new ListView(
|
||||||
UsernameField(),
|
shrinkWrap: true,
|
||||||
Padding(
|
padding: const EdgeInsets.all(20.0),
|
||||||
padding: const EdgeInsets.all(10),
|
children: [
|
||||||
child: Center(
|
new UsernameField(),
|
||||||
child: TextField(
|
new PasswordField(),
|
||||||
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;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
))),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,3 +58,39 @@ class UsernameField extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PasswordField extends StatefulWidget {
|
||||||
|
const PasswordField({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_PasswordFieldState createState() => _PasswordFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PasswordFieldState extends State<PasswordField> {
|
||||||
|
bool _isPasswordObscure = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return 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;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
))),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user