skip to Main Content

I have a ListView of cards. Clicking on a card takes you to a detailed page. I push the screen using context.pushNamed via GoRouter. Upon clicking on back <, I am always taken to the beginning of the list.

I want to preserve the scrolling offset when back to the list view page.

2

Answers


  1. You can prevent the screen from rebuilding when you navigate back to the listview screen by using the buildWhen property from the flutter_bloc package.

    Login or Signup to reply.
  2. You can pass the offset of the ListView (using a ScrollController to handle that value), or you can use the id of the detailed item itself, when going back use the result parameter and pass the previous offset or id of the item and use the ScrollController from the ListView to scroll to that position (either directly the offset or the position of the item in the list).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search