I am trying to create TabBar which would be located in the middle of the page (Description widget must be at the top).
The problem is that I have to manually set the height of the Container widget which contains TabBarView. If I leave it without this height, I get error Horizontal viewport was given unbounded height.
.
Top level widget:
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(),
body: SingleChildScrollView(
child: Column(
children: <Widget>[Description(), Tabs()],
),
),
);
}
Tabs widget:
class Tabs extends StatelessWidget {
final _tabs = [
Tab(
icon: Icon(Icons.menu),
text: 'Menu',
),
Tab(
icon: Icon(Icons.mode_comment),
text: 'Reviews',
)
];
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: _tabs.length,
child: Column(
children: <Widget>[
TabBar(
labelColor: PickColors.black,
indicatorSize: TabBarIndicatorSize.tab,
tabs: _tabs,
),
Container(
width: double.infinity,
height: 200, // I need to remove this and make height dynamic
child: TabBarView(
children: <Widget>[MenuTab(), ReviewsTab()],
),
),
],
));
}
}
Since Tabs content will be dynamic, the height will also be. I cannot use static height here.
Is there an alternative for the Container with static height? How can I make my tabs' height dynamic?