@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: defaultBackgroundColor),
child: Stack(children: [
Image.asset(
'assets/background/around.jpg',
width: MediaQuery.of(context).size.width,
height: 400,
fit: BoxFit.fill,
),
SingleChildScrollView(
child: Column(
children: <Widget>[
AroundHeader(),
TabBar(
controller: _tabController,
unselectedLabelColor: Colors.white,
indicatorSize: TabBarIndicatorSize.tab,
labelColor: Colors.blue,
indicator: BoxDecoration(
color: Colors.transparent,
border:
Border(bottom: BorderSide(color: Colors.blue, width: 3)),
),
tabs: [
...data.map(
(item) => Tab(
child: Container(
child: Align(
alignment: Alignment.center,
child: Text(item, style: titleStyle),
),
),
),
),
],
),
SizedBox(height: 10),
Padding(
padding: const EdgeInsets.symmetric(vertical: commonMargin),
child: Container(
height: MediaQuery.of(context).size.height + 300,
width: MediaQuery.of(context).size.width - 2 * commonMargin,
child: TabBarView(
controller: _tabController,
children: <Widget>[
AroundRecommend1(),
AroundRecommend2(),
AroundRecommend3(),
AroundRecommend4(),
],
),
),
),
],
),
),
]),
);
}
Explanded
或SizedBox.expand
或IntrinsicHeight
替换受约束的容器,依此类推,但是它们都失败了,但没有提供高度之类的例外。答案 0 :(得分:1)
您希望将小部件包装在Expanded
的列中,而不是Column
本身
Column(
children: <Widget>[
Expanded(
child: Container(
height: 200,
color: Colors.redAccent,
),
),
],
);