I'm trying to create a custom TabBar using PreferredSize, but I can't meld the color of the TabBar with my body, there seems to be a border between the TabBar and the body. The picture below will show you clearly what I'm trying to accomplish.
I have tried to create a border with the same color as the body with large width, but it doesn't seems to work. Here is my code:
Widget _buildAppBar(context) {
return AppBar(
title: Text(title),
elevation: 0,
flexibleSpace: Image.asset(
'images/motif_batik_01.jpg',
fit: BoxFit.cover,
width: 1200,
),
bottom: _buildTabBar(context)
);
}
Widget _buildTabBar(context) {
return PreferredSize(
preferredSize: Size.fromHeight(100.0),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).backgroundColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
padding: EdgeInsets.only(
top: 50,
left: 20,
right: 20,
),
height: 100,
child: TabBar(
indicator: BoxDecoration(
color: Colors.orange, borderRadius: BorderRadius.circular(20)
),
labelStyle: TextStyle(color: Colors.white),
unselectedLabelColor: Colors.orange,
tabs: <Widget>[
Tab(child: Text('A', style: TextStyle(fontSize: 18.0))),
Tab(child: Text('B', style: TextStyle(fontSize: 18.0))),
],
),
)
);
}
Edit Notes: I figured out that if my 'preferedSize' is a multiplication of 40.0 (40.0, 80.0) the line disappears, could it be a bug in the flutter itself?
By default, a TextField is decorated with an underline. You can add a label, icon, inline hint text, and error text by supplying an InputDecoration as the decoration property of the TextField . To remove the decoration entirely (including the underline and the space reserved for the label), set the decoration to null.
Just wrap the TabBar in an IgnorePointer. This should be the correct and easiest answer.
To change tab bar background color in Flutter, first, create a getter to return the TabBar widget and then wrap the TabBar widget inside the PreferredSize -> Material widget. Inside the Material add the color property and set the color of your choice.
Add indicator color to tabBar and color to transparent.
indicatorColor: Colors.transparent
indicator:BoxDecoration()
or
indicatorColor:Colors.transparent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With