ListView loses scroll position when using InheritedWidget in Flutter
Asked Answered
M

1

8

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

Mcilroy answered 29/4, 2019 at 6:5 Comment(2)
We lack information. Maybe insert some code to help us reproduce the errorHubble
The problem in this case was in wrong way to implementing GlobalKey for some widgets inside ListView. So it wasn't InheritedWidget's problemMcilroy
B
23

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
);
Batten answered 1/5, 2019 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.