1

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!

asked Mar 13, 2022 at 0:47
1
  • 1
    You need to use sliverAppBars. You can find a quick intro here youtu.be/R9C5KMJKluE Commented Mar 13, 2022 at 1:45

1 Answer 1

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.

answered Mar 13, 2022 at 1:51
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.