Reputation: 19
I'm experiencing an issue with a SliverAppBar in my Flutter app. There's an unwanted space in the SliverAppBar that appears in blue color, and I can't seem to remove it.
Here is a simplified version of my code:
SliverAppBar(
collapsedHeight: 56,
elevation: 0,
scrolledUnderElevation: 0,
backgroundColor: Colors.blue,
expandedHeight: _appBarHeight,
floating: false,
pinned: false,
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.black.withOpacity(0.5), // Set the status bar color
statusBarIconBrightness: Brightness.light, // Set the status bar icon brightness
statusBarBrightness: Brightness.light, // Set the status bar brightness (for iOS)
),
leading: Container(
margin: const EdgeInsets.all(8.0),
decoration: const BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: IconButton(
icon: const Icon(Icons.arrow_back, color: Color(0xff333333)),
onPressed: () => Navigator.of(context).pop(),
),
),
flexibleSpace: FlexibleSpaceBar(
background: _buildImageCarousel(),
),
),
I've tried adjusting padding and margin properties, but the unwanted space still remains. How can I remove this extra space? Is there a specific property or method I should be using to ensure the SliverAppBar fits correctly without the additional blue space?
Any help or guidance would be greatly appreciated!
Upvotes: 0
Views: 53
Reputation: 3309
Try to set fit: BoxFit.Cover
for that image represented in the sliver app bar.
and
For your carousel slider, you shouldn't impose any constraints on it, which help to cover all the space in the sliver app bar.
and try the following:
background: Column(
children:[
Expanded(
child : YourCarousel()
)
]
)
Upvotes: 0