Scroll back to top on BottomNavigationBar - flutter - flutter

I am making an app that has a BottomNavigationBar with 3 items, the first one is the Home page and it contains a ListView of items.
What i want to do is make the ListView scroll back to top when the Home button in the BottomNavigationBar is pressed.
Is there a way to do so?

initiate ScrollController for ListView
use onTap from BottomNavigationBar and get the current index
in onTap func, determine index == 0 and scrollController.jumpTo(0.0);

Related

above widgets are done by pageview builder and below is listview builder

I want to make it responsive like if I move the slider then correspondent list which is below should be highlighted and should move according to the slider.
I have tried PageView controller to pass in ListView controller but it never worked.

Scroll down event to show appbar based on category - Flutter

I have an AppBar and other things in my layout. When user scrolls down, I want AppBar(actually, the Toolbar to show based on category).
How to achieve this appbar appear when scrolling the listview ?
Here the example i want to make like this.
Before scrolling
After Scrolling Appbar Appear and fixed at top

Flutter: How to animate between pages with BottomNavigationBar

I'm building an app with multiple pages. There are going to be some common elements. I want to wrap them in Hero() widgets so that they animate from one screen to another.
The problem is that the bottom navigation bar cuts between widgets. The way I currently have it is that I have a Home() widget that has a Scaffold(). The scaffold has a body which returns a widget (different pages) and a BottomNavigationBar(). Is there a way I can make a route be inside of the home's body widget or to add a route animation to the bottom navigation bar or other solutions that could fix this problem?
I don't want to have to make each page have a bottom navigation bar of it's own and route between them and I'd prefer to have the bottom navigation bar inside of the parent widget. How can I achieve this?
Thanks for your help!
I fixed it by having to put a bottom navigation bar in each page. I made it simpler by making a widget for it that takes in the page index so that I can just code it once and just put the widget on each page and write it's index.

Auto Scrolling in Flutter

So I have a SingleChildScrollView() whose child is a Column() with different widgets inside it. I have 3 BUTTONS on the app bar. Each for 3 widgets I want to jump to.
When I press the button, I want the UI to automatically scroll to the mapped Widget. Just like we see that effect in websites.
How can I achieve this ?
You can create a ScrollController and pass it to the controller parameter of your scrolling widget. Then you can use the animateTo method to animate to an offset.
Ex.
ScrollController controller = ScrollController();
//In build
SingleChildScrollView(
controller: controller,
child: ...,
)
//In each button onPressed/onTap
controller.animateTo(offset);

Animate replacing widget in flutter

I am replacing widgets to navigate. using bottom navigation bar
Following this video tutorial
so when an item is pressed on the nav bar, basically the widget that scaffold's body contains is replaced with another. So is it possible to animate this change ? if so how ? I am a very beginner in flutter.