如何解决Flutter小部件第二行消耗剩余空间
我还很陌生,很多事情我还不了解。我已经尝试了很多东西,但还没有得到想要的东西。任何建议都会有所帮助。
Widget build(BuildContext context) {
return Column(children: [
Expanded(
child: Container(
// make the full container the amber color
color: Colors.amber[600],child: Column(children: [
Row(children: [
Expanded(
child: Text(
windowName,style: TextStyle(
backgroundColor: Colors.blueGrey[200],fontSize: 24,fontWeight: FontWeight.bold),),IconButton(
onPressed: onCurrentDelete,icon: Icon(Icons.delete_outline,size: 32)),]),//IntrinsicHeight(
// child:
Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,children: [
Expanded(
child: Container(
// make the left container blue
color: Colors.blue[600],//constraints: BoxConstraints.expand(),//decoration: BoxDecoration(
// border: Border.all(
// width: 2,//)),child: Text(
startTime,style: TextStyle(
backgroundColor: Colors.blueGrey[200],fontSize: 16,fontWeight: FontWeight.normal),)),Expanded(
child: Container(
// make the right container green
color: Colors.green[600],child: Text(
endTime,)
],//),)
]);
我想要的是最后一行中的两个容器占用剩余空间。我已经使用color属性显示特定小部件的大小。
蓝色和绿色容器需要填充到琥珀色部分的底部。
我尝试了许多替代方法,并且每次在渲染小部件时都会产生错误。
解决方法
我希望这是您要寻找的东西:
代码:
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Column(children: [
Expanded(
child: Container(
// make the full container the amber color
color: Colors.amber[600],child: Column(children: [
Row(children: [
Expanded(
child: Text(
"windowName",style: TextStyle(
backgroundColor: Colors.blueGrey[200],fontSize: 24,fontWeight: FontWeight.bold),),IconButton(
onPressed: () {},icon: Icon(Icons.delete_outline,size: 32)),]),//IntrinsicHeight(
// child:
Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,children: [
Container(
// make the left container blue
color: Colors.blue[600],//constraints: BoxConstraints.expand(),//decoration: BoxDecoration(
// border: Border.all(
// width: 2,//)),child: Text(
"startTime",style: TextStyle(
backgroundColor: Colors.blueGrey[200],fontSize: 16,fontWeight: FontWeight.normal),)),SizedBox(
width: MediaQuery.of(context).size.width * 0.4,Container(
// make the right container green
color: Colors.green[600],child: Text(
"endTime",))
],//),)
]),);
}
,
代码:
Column(children: [
Expanded(
child: Container(
// make the full container the amber color
color: Colors.amber[600],child: Column(mainAxisSize: MainAxisSize.max,children: [
Row(children: [
Expanded(
child: Text(
'windowName',style: TextStyle(
backgroundColor: Colors.blueGrey[200],IconButton(
onPressed: () {},//IntrinsicHeight(
// child:
Row(
//crossAxisAlignment: CrossAxisAlignment.stretch,children: [
Expanded(
child: Container(
height: 300,// make the left container blue
color: Colors.blue[600],//decoration: BoxDecoration(
// border: Border.all(
// width: 2,child: Text(
'startTime',style: TextStyle(
backgroundColor: Colors.blueGrey[200],Expanded(
child: Container(
height: 300,// make the right container green
color: Colors.green[600],child: Text(
'endTime',)
],)
])
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。