I've searching for a solution for this: I have a headline in my view and I want to show the headline only on top, when I'm scrolling down. This is my current example: enter image description here
So the blue headline should only appear if I'm scrolling down. Do you have any ideas, how to do this?
Thanks, Sir!
-
1You need to use sliverAppBars. You can find a quick intro here youtu.be/R9C5KMJKluEAnkit Kumar Maurya– Ankit Kumar Maurya2022年03月13日 01:45:34 +00:00Commented Mar 13, 2022 at 1:45
1 Answer 1
You can use this approach:
Define global variable called isScrollingDown.
Create a function that checks whether the user scrolling down or up.
void checkScrollDirection() {
if (scrollController.position.userScrollDirection == ScrollDirection.reverse) {
isScrollingDown = true;
} else {
isScrollingDown = false;
}
}
Give this function to your scrollcontroller as a listener.
scrollController.addListener(checkScrollDirection);
After that manage visibility of AppBar with isScrollingDown condition. You can do with either Visibility widget or AnimatedContainer etc.
Comments
Explore related questions
See similar questions with these tags.