我正在尝试复制以下设计:
我似乎不明白为什么我的子小部件TabBarView
会导致异常。提到了无限高度,但我提供了子小部件的高度和宽度,所以我对发生的事情感到困惑......
仅供参考:TripPage
小部件(代码中未显示,只有其状态)作为值传递给 a 的 body 属性Scaffold
(也未显示)。我不想改变这一点。
这是我的代码:
class _TripPageState extends State<TripPage> {
//ToDo: Keep as dynamic until an object is created for the listItems.
List<dynamic> upcomingTrips;
List<dynamic> pastTrips;
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Row(mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[
Padding(
child: Text(
"Trips",
style: TextStyle(
color: Colors.deepPurple,
fontSize: 36.0,
fontWeight: FontWeight.bold),
),
padding: EdgeInsets.only(top: 40.0, left: 28.0),
)
]),
DefaultTabController(
length: 2,
child: Column(mainAxisSize: MainAxisSize.max, children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 16.0, top: 24.0),
child: Row(children: <Widget>[
TabBar(
tabs: <Widget>[
Tab(text: "Upcoming".toUpperCase()),
Tab(text: "Past".toUpperCase())
],
isScrollable: true,
indicatorColor: Colors.deepPurple,
labelColor: Colors.black,
unselectedLabelColor: Color.fromRGBO(78, 78, 81, 30),
)
])),
TabBarView(
children: <Widget>[
Container(
color: Colors.pink,
child: Image.asset('assets/saved_flights_icon.jpg',
width: 200.0, height: 200.0)),
Container(
color: Colors.greenAccent,
child: Image.asset('assets/saved_flights_icon.jpg',
width: 200.0, height: 200.0)),
// UpcomingTripsTabPage(),
// PastTripsTabPage()
],
)
]),
)
],
);
}
}
但是,我的堆栈跟踪中出现以下消息:
I/flutter ( 7054): The following assertion was thrown during performResize():
I/flutter ( 7054): Horizontal viewport was given unbounded height.
I/flutter ( 7054): Viewports expand in the cross axis to fill their container and constrain their children to match
I/flutter ( 7054): their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of
I/flutter ( 7054): vertical space in which to expand.
随后是几条关于RenderBoxes
,RenderViewports
等的消息。
提前致谢!