I am creating a simple web portfolio to have hand-on practice in flutter. I was wondering how other website work when we click on home/about/contact button the web scroll to that specific widget.
I tried to do this but didn’t get it how to implement this functionality
Code example will be helpful and will be appreciated as upvote.
3
Answers
you can give global key to the widget you want to scroll to
e.g
assign it to the widget
and then on the button onpressed write this code
you could use this package
scroll_to_id
and here is an exemple made by github@yusukeinouehatchout
I faced the same problem but I managed to solve it with this package it’s helpful and easy scroll_to_index
define a listview controller
ListView( controller: controller, )
then you just need to wrap the elements in your screen with
AutoScrollTag
like)
finally scroll to our element like this
controller.scrollToIndex(index, preferPosition: AutoScrollPosition.begin)