Reputation: 37
I have the following TabBar (I've used flexibleSpace to remove the padding an empty AppBar would put above the TabBar and SafeArea such that the TabBar doesn't appear under the android status bar):
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
flexibleSpace: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TabBar(
indicatorColor: Color(0xfffffffe),
tabs: [
Tab(
text: "Diary",
icon: Icon(Icons.book),
),
Tab(
text: "Charts",
icon: Icon(Icons.insert_chart),
),
Tab(
text: "Settings",
icon: Icon(Icons.settings),
)
],
),
],
),
),
),
body: TabBarView(
children: [
Diary(),
Charts(),
Settings(),
],
)
)
),
It looks like this when rendered:
How can I avoid the bottom overflow while still maintaining the safe area and flexibleSpace?
Upvotes: 0
Views: 2122
Reputation: 2664
If you wrap your TabBar
in an Expanded
widget it should solve your problem
AppBar(
flexibleSpace: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expanded(
child: TabBar(
indicatorColor: Color(0xfffffffe),
tabs: [
Tab(
text: "Diary",
icon: Icon(Icons.book),
),
Tab(
text: "Charts",
icon: Icon(Icons.insert_chart),
),
Tab(
text: "Settings",
icon: Icon(Icons.settings),
)
],
),
),
],
),
),
),
Let me know how this works for you.
Upvotes: 2
Reputation: 1407
Removing the SafeArea and the Column should fix the problem:
appBar: AppBar(
flexibleSpace: TabBar(
indicatorColor: Color(0xfffffffe),
tabs: [
Tab(text: "Diary",
icon: Icon(Icons.book),),
Tab(text: "Charts",
icon: Icon(Icons.insert_chart),),
Tab(text: "Settings",
icon: Icon(Icons.settings),)
],
),
),
Upvotes: 1