Flutter : keeping list view index while changing Page View

Paul Boldijar
1 min readMar 9, 2018

--

A really annoying issue that I recently found when working with lists in flutter, is that in some cases, you will loose the current scroll position.

Maybe my issue is similar to https://github.com/flutter/flutter/issues/8101 but still, is not working after they fixed it.

In my case, I had to show a page view, with some bottom navigation widget under.

How it looks:

If you look closely you’ll see that the item position is reset.

The code that generates the above UI:

The same issue was reported on stackoverflow and Marcin Szałek came with a solution, that I modified a little bit to be more generic, and be able to reuse in many places, creating a StatefulListView

And in the end, the final code that will save the list position:

--

--

Paul Boldijar
Paul Boldijar

Responses (4)