Search code examples
dartflutterinherited-widget

ListView loses scroll position when using InheritedWidget in Flutter


After adding InheritedWidget to app I recognize that ListView loses scroll position (selected item index) when I come back to list from details screen using Pop().

I know that widget can be rebuild any time but maybe someone can suggest solution without handling cache manually.

P.S. Scroll position was fine before implementing InheritedWidget


Solution

  • no any code so a shot in the dark

    try to add 'key' like this

    ListView(
       key: const PageStorageKey<String>('some unique text'),
       //other parameters
    );