Flutter 在屏幕底部的一列中,将容器与按钮对齐
我的代码:Flutter 在屏幕底部的一列中,将容器与按钮对齐,flutter,dart,Flutter,Dart,我的代码: return Scaffold( drawer: Drawer(), backgroundColor: Color(0xFFF6F4F2), body: Column( children: <Widget>[ Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget&
return Scaffold(
drawer: Drawer(),
backgroundColor: Color(0xFFF6F4F2),
body: Column(
children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'images/emblem.png',
height: 80,
),
SizedBox(
width: 20,
),
Text(
'Connect',
style: TextStyle(color: Colors.white, fontSize: 40),
),
],
),
height: 120,
width: 1000,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: _colors,
stops: _stops,
),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(100),
bottomRight: Radius.circular(100),
)),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
AltButton(
label: 'Contacts',
icon: FontAwesomeIcons.phone,
routeString: ContactsScreen.id,
),
AltButton(
label: 'CGHS Codes',
icon: FontAwesomeIcons.calculator,
routeString: CGHSCodesScreen.id,
),
Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
InkWell(
onTap: () {},
child: Container(
margin: EdgeInsets.only(left: 20, right: 20, top: 10),
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Color(0xFFFFFFFF),
borderRadius: BorderRadius.circular(25),
boxShadow: [
new BoxShadow(
spreadRadius: 1,
offset: Offset.fromDirection(
120,
5,
),
color: Colors.green[300],
blurRadius: 10.0,
),
],
),
child: Row(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.all(10),
child: InkWell(
child: FaIcon(
FontAwesomeIcons.signInAlt,
color: Color(0xFF237158),
size: 20,
),
radius: 30,
splashColor: Colors.lightGreen,
hoverColor: Colors.lightGreen[50],
),
),
SizedBox(
width: 15,
),
Text(
'Login',
style: TextStyle(
fontSize: 25, color: Colors.green[700]),
),
],
),
),
),
],
),
_loggedIn
? Container()
: AltButton(
label: 'Login',
icon: FontAwesomeIcons.user,
routeString: LoginScreen.id,
),
],
)
],
),
);
正确的方法是什么?将其添加到包含按钮的列中,尝试使用
LayoutBuilder
以便轻松解决此类问题
LayoutBuilder(
builder: (_, constraints) {
return Container(
width: constraints.maxWidth,
height: constraints.maxHeight,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
//your first 2 button
],
),
),
Container(
child: //your bottom button,
),
],
),
);
},
),
LayoutBuilder(
构建器:(ux,约束){
返回容器(
宽度:constraints.maxWidth,
高度:constraints.maxHeight,
子:列(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
货柜(
子:列(
mainAxisAlignment:mainAxisAlignment.start,
儿童:[
//你的第一个2按钮
],
),
),
容器(
点击底部按钮,
),
],
),
);
},
),
addSpacer()
在ColumnAddExpanded(child:Container())窗口小部件中的登录按钮元素之前添加最后一个按钮。@GenchiGenbutsu导致RenderFlex子项具有非零弹性,但传入的高度约束是无限的。
异常。
LayoutBuilder(
builder: (_, constraints) {
return Container(
width: constraints.maxWidth,
height: constraints.maxHeight,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
//your first 2 button
],
),
),
Container(
child: //your bottom button,
),
],
),
);
},
),