I’ve having many issues trying to overlap a custom Rounded Container that has different widgets inside, in a Sliver App Bar. I’ve seen it was a very common problem a few years ago, but I couldn’t find anything that worked for me.
I’ve tried different ways to achieve it, with a Stack at the beginning, with a Stack in the flexibleSpace of the Sliver App Bar, with Persistant Header, but nothing worked.
What I need is very simple.
I have this (https://i.sstatic.net/jydnIRBF.png)
And what I need is to get the Rounded Container a few pixels over the image.
This is my code:
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: Stack(
children: [
CustomScrollView(
slivers: [
SliverAppBar(
backgroundColor: Theme.of(context).colorScheme.background,
stretch: true,
onStretchTrigger: () async {},
forceElevated: true,
pinned: true,
expandedHeight: SizeConfig.screenHeight * 0.3,
flexibleSpace: FlexibleSpaceBar(
background: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
bottom: 0,
child: Image.asset(
'assets/images/sign-up-bg.jpg',
fit: BoxFit.cover,
),
),
],
),
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => TopRoundedContainer(
size: EdgeInsets.only(
top: SizeConfig.screenHeight * 0.25,
),
color: Theme.of(context).colorScheme.secondary,
padding: EdgeInsets.only(
top: SizeConfig.screenHeight * 0.04,
),
child: Column(
children: [
CustomButton(
text: 'Edit Profile',
press: () {
Navigator.pushNamed(
context,
PhotographerEditProfile.routeName,
);
},
buttonColor: Theme.of(context).colorScheme.background,
textColor: Theme.of(context).colorScheme.surface,
),
],
),
),
childCount: 1,
),
),
],
),
],
),
);
Fermin Lasarte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.