Adding shadow to a single side is very hard since it's a shifted and blurred version of the parent widget. I tried all the other ways but didn't work really well.
for longer shadow.
I also found one other way is by use Stack
Widget to cover the other sides. If you don't have anything near that widget. if you have a widget near it, you can use that widget to cover the shadow.
Please refer to the code below.
Stack(alignment: Alignment.topCenter, children: [
Padding(
padding: EdgeInsets.only(top: 14),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0xff000000).withOpacity(0.1),
spreadRadius: 0,
blurRadius: 10,
offset: Offset(0.0, 4),
// // changes position of shadow
),
],
),
child: TabBar(
indicatorColor: Color(0xffFF7000),
unselectedLabelColor: Color(0xff818898),
labelColor: Color(0xffFF7000),
tabs: [
Tab(
child: Text(
'Tab 0'
style: TextStyle(
fontSize: UiSizeUtils.getFontSize(14),
fontWeight: FontWeight.w600),
),
),
Tab(
child: Text(
'Tab 1'
style: TextStyle(
color: Color(0xff8D99BB),
fontSize: UiSizeUtils.getFontSize(14),
fontWeight: FontWeight.w600),
),
),
],
controller: _tabController,
indicatorSize: TabBarIndicatorSize.tab,
),
),
),
Container(
width: double.infinity,
height: UiSizeUtils.getHeightSize(16),
color: Colors.white,
)
]),
This is how I added the shadow for the bottom only for the tab view and this works best for my use case when compared with the other method mentioned above.