我正在尝试构建一个非常简单的登录页面,并且我希望“注册”文本位于屏幕底部。
我正在尝试将最后一列中的文本与屏幕底部对齐,但是以某种方式无法进行调整。
当我尝试使用Expanded窗口小部件时,IDE向我抛出一个绘制错误。
class EmailLogin extends StatefulWidget {
@override
_EmailLoginState createState() => _EmailLoginState();
}
class _EmailLoginState extends State<EmailLogin> {
final Map<String, dynamic> _formData = {'email': null, 'password': null};
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Widget _emailTextField() {
return TextFormField(
decoration: InputDecoration(
labelText: 'Email',
),
keyboardType: TextInputType.emailAddress,
},
onSaved: (String value) {
_formData['email'] = value;
},
);
}
Widget _passwordTextField() {
return TextFormField(
obscureText: true,
validator: (String value) {
if (value.isEmpty || value.length < 6) {
return "please enter valid password";
}
},
onSaved: (String value) {
_formData['password'] = value;
},
decoration: InputDecoration(
labelText: 'Password',
),
);
}
Widget _passwordConfirmTextField() {
return TextFormField(
obscureText: true,
validator: (String value) {
if (value.isEmpty || value.length < 6) {
return "please enter valid password";
}
},
onSaved: (String value) {
_formData['password'] = value;
},
decoration: InputDecoration(
labelText: 'Password',
),
);
}
void _submitForm() {
if (!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
print(_formData);
Navigator.of(context).pushNamed('/home');
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
Image(
image: AssetImage("assets2/car.jpg"),
fit: BoxFit.cover,
color: Colors.black87,
colorBlendMode: BlendMode.darken,
),
SingleChildScrollView(
child: Form(
key: _formKey,
child: Container(
width: double.infinity,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 80.0),
child: Logo(),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 8.0, bottom: 80.0),
child: Text(
"Airbnb",
style: TextStyle(fontSize: 30.0),
),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: _emailTextField()),
SizedBox(
height: 15.0,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: _passwordTextField()),
Row(
children: <Widget>[
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 20.0, right: 5.0, top: 10.0),
child: GestureDetector(
onTap: () {
_submitForm();
},
child: Container(
alignment: Alignment.center,
height: 60.0,
decoration: BoxDecoration(
color: Color(0xFF18D191),
borderRadius: BorderRadius.circular(10.0)),
child: Text(
'login',
style: TextStyle(
fontSize: 20.0, color: Colors.white),
),
),
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(
left: 10.0, right: 20.0, top: 10.0),
child: Container(
alignment: Alignment.center,
height: 70.0,
child: Text(
'Forgot Password?',
style: TextStyle(
fontSize: 15.0, color: Color(0xFF18D191)),
),
),
),
),
],
),
Column(
children: <Widget>[
Container(
child: Text("switch to sign up"),
alignment: Alignment.bottomCenter,
),