I have implemented a SliverAppBar in my Flutter app, but I'm having trouble getting the back button to show up on the left side of the app bar. I've set the leading property of the SliverAppBar to a BackButton, but the button doesn't appear.
the back. the button exists and is clickable but I cannot see it
and I can see the tooltip when I click on it
here is my code
class TabBarWidget extends StatelessWidget with PreferredSizeWidget {
const TabBarWidget(
{Key? key,
required this.tabController,
required this.tabs,
this.onTap,
required this.height})
: super(key: key);
final TabController tabController;
final double height;
final List<Widget> tabs;
final ValueChanged<int>? onTap;
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
// I can see the back button when I delete this container
Container(
height: 120,
decoration: const ShapeDecoration(
color: AppColors.primaryColor,
shape: CustomShapeBorder(180),
),
),
Container(
color: Colors.white,
child: TabBar(
controller: tabController,
labelColor: AppColors.boldRedColor,
onTap: onTap,
unselectedLabelStyle: const TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
),
labelStyle: const TextStyle(
fontWeight: FontWeight.bold,
color: AppColors.boldRedColor,
),
unselectedLabelColor: Colors.grey,
indicatorColor: AppColors.boldRedColor,
tabs: tabs,
),
),
],
);
}
@override
// TODO: implement preferredSize
Size get preferredSize => Size.fromHeight(kToolbarHeight + height);
}
SliverAppBar(
backgroundColor: AppColors.primaryColor,
foregroundColor: Colors.white,
leading: const BackButton(
color: Colors.white,
),
iconTheme: const IconThemeData(
color: Colors.red,
),
title: const Text('title'),
pinned: true,
bottom: TabBarWidget(
tabController: _tabController,
tabs: tabs,
height: _tabController.index != 0 ? 0 : 180,
onTap: (index) {
setState(() {});
},
),
),