【发布时间】:2019-05-04 00:51:43
【问题描述】:
我是 Flutter 的新手,我正在尝试将所有小部件置于列小部件的中心,但它不起作用。我尝试将列封装到中心小部件中,但它仍然相同并与屏幕顶部对齐。下面是我的代码,请看一下,让我知道我做错了什么。谢谢:)
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SignIn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Padding(
padding: EdgeInsets.all(15.0),
child: Column(
children: <Widget>[
Text(
'SignIn Screen',
style: TextStyle(fontSize: 26.0),
),
Padding(
padding: EdgeInsets.only(top: 30.0),
),
TextField(
maxLength: 25,
decoration: InputDecoration(
hintText: 'Enter username',
),
),
TextField(
maxLength: 25,
decoration: InputDecoration(
hintText: 'Enter password',
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
RaisedButton(
child: Text('SignIn'),
onPressed: _signIn,
),
],
),
),
],
),
),
);
}
Future _signIn() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setBool('isLoggedIn', true);
}
}
【问题讨论】:
标签: android flutter flutter-layout