I want a widget to be place below the app while scrolling the screen . The screen contains a floating app bar with flexible space ( sliverappbar) and below it one conatiner which have any container or tab view . The video in the link is the example of the effect i wanted.
Asked
Active
Viewed 1.0k times
2 Answers
15
Alright, I think I understand you now. You'll need to implement a CustomScrollView
CustomScrollView(
slivers: <Widget>[
SliverAppBar(
// Your appbar goes here
),
SliverPersistentHeader(
pinned: true,
delegate: PersistentHeader(
widget: Row(
// Format this to meet your need
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Hello World'),
Text('Hello World'),
Text('Hello World'),
],
),
),
),
],
),
Create a new class for the Persistent header, which extends a SliverPersistentHeaderDelegate as shown:
class PersistentHeader extends SliverPersistentHeaderDelegate {
final Widget widget;
PersistentHeader({this.widget});
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Container(
width: double.infinity,
height: 56.0,
child: Card(
margin: EdgeInsets.all(0),
color: Colors.white,
elevation: 5.0,
child: Center(child: widget),
),
);
}
@override
double get maxExtent => 56.0;
@override
double get minExtent => 56.0;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
}
Let me know if you encounter any other issue.

Chichebe
- 580
- 5
- 12
-
Thanks, this is great. Any idea how to stop it from going behind the status bar? – Chris May 31 '22 at 09:25
-
Have you been able to figure this out yet? @Chris – Chichebe Jun 17 '22 at 07:26
-
no I gave up on this one in the end. Couldn't get it to do what I wanted – Chris Jun 17 '22 at 10:50
1
I have an idea of a solution to your particular problem, having recently implemented something quite similar or identical to what you want, but I can't find the link you talked about to the video of the effect you're trying to achieve. Could you edit and upload the link to the video so I can view to enable me to render the precise solution to your problem?

Chichebe
- 580
- 5
- 12
-
https://drive.google.com/file/d/1PhEBRzoZgYhKrJ5xK2xe2ebOWqw2_8vW/view?usp=drivesdk <---- as this is not the exact the want i wanted but you can see in this video below appbar there is widget which is pin above the list view . – ankit jain Apr 24 '20 at 17:26