I’m getting a bottom underline in the TabBar. I tried to remove it. but its not removing.
(https://i.sstatic.net/CbDf57Nr.png)
Widget build(BuildContext context) {
TabController tabController = TabController(length: 2, vsync: this);
return Scaffold(
backgroundColor: Palette.white,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(color: const Color(0x1E767680), borderRadius: BorderRadius.circular(7)),
height: 36,
child: TabBar(
indicatorSize: TabBarIndicatorSize.tab,
indicatorPadding: const EdgeInsets.all(2),
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: Colors.deepPurple,
),
controller: tabController,
labelStyle: const TextStyle(color: Colors.white, fontSize: 13, fontWeight: FontWeight.w500),
unselectedLabelStyle: const TextStyle(color: Color(0xFF5B5B5B), fontSize: 13, fontWeight: FontWeight.w400),
indicatorWeight: 0,
indicatorColor: Colors.transparent,
tabs: const [
Tab(text: 'Page 1'),
Tab(text: 'Page 2'),
],
),
),
const SizedBox(height: 16),
//TabBarView
Expanded(
child: TabBarView(
controller: tabController,
children: [
_buildAttendanceView(),
Tab2(),
],
),
)
],
), );
I tried,
border: Border.all(color: Colors.transparent) to remove any visible border.
indicatorWeight: 0:
indicatorColor: Colors.transparent:
Wrap the TabBar widget inside a Material widget and set borderOnForeground to false.
but didnt work.
Star Shadow is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
It sounds like you’re dealing with an unwanted underline or border at the bottom of the TabBar
. You’ve already tried some approaches like setting indicatorWeight
to 0
, indicatorColor
to transparent
, and wrapping the TabBar
in a Material
widget, but the underline persists.
To remove the underline, try the following adjustments:
1. Set the indicator
to null
:
If you don’t want any underline or indicator at all, you can set the indicator
property of the TabBar
to null
.
2. Remove the indicatorWeight
:
Ensure that the indicatorWeight
is completely removed since setting it to 0
might still cause issues.
Here’s how your code could look with these adjustments:
Widget build(BuildContext context) {
TabController tabController = TabController(length: 2, vsync: this);
return Scaffold(
backgroundColor: Palette.white,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
color: const Color(0x1E767680),
borderRadius: BorderRadius.circular(7)
),
height: 36,
child: TabBar(
controller: tabController,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(7),
color: Colors.deepPurple,
),
labelStyle: const TextStyle(
color: Colors.white,
fontSize: 13,
fontWeight: FontWeight.w500
),
unselectedLabelStyle: const TextStyle(
color: Color(0xFF5B5B5B),
fontSize: 13,
fontWeight: FontWeight.w400
),
tabs: const [
Tab(text: 'Page 1'),
Tab(text: 'Page 2'),
],
),
),
const SizedBox(height: 16),
// TabBarView
Expanded(
child: TabBarView(
controller: tabController,
children: [
_buildAttendanceView(),
Tab2(),
],
),
),
],
),
);
}
3. Ensure the TabBar is not inside a Material widget with a borderOnForeground
setting:
If you have wrapped the TabBar
inside a Material
widget elsewhere, ensure that borderOnForeground
is not interfering.
4. Check for Other Widgets:
If none of the above works, double-check other widgets wrapping the TabBar
, like Container
or any parent Material
widget, to ensure they aren’t causing any unintended styling issues.
This should resolve the unwanted underline in the TabBar
. If the issue persists, please let me know, and we can explore further adjustments.
SUMIT KUMAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.