Home > Blockchain >  Flutter scrolling behavoir
Flutter scrolling behavoir

Time:03-14

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!

CodePudding user response:

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.

CodePudding user response:

Use Silver Scrolls or Nested Scrolls.

  • Related