Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

[ScrollablePositionedList] PageStorage cast bug #514

@SoftWyer

Description

@SoftWyer

Problem description

The ScrollablePositionedList stores its scroll offset as an ItemPosition in PageStorage. However, mixing this widget with other scrollable widgets can cause a cast issue as other scrollables use a pixel offset (double) not an ItemPosition.

Steps to reproduce

Create an app that uses the ScrollablePositionedList in portrait mode but another type of list in landscape mode and rotate the device. A cast error will be shown as the different lists try to read PageStorage and cast it to different Types.

Note: This may be exacerbated by a context related bug in the app implementing the lists, but it's still a potential issue in the implementation of the scrollable list widget.

Expected behaviour

No cast exception on rotation.

Actual behaviour

Cast exception on rotation

Environment

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.22631.3085], locale en-GB)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.4)
[√] Android Studio (version 2023.1)
[√] Connected device (4 available)
[√] Network resources

• No issues found!

Additional details

A fix for this issue can be seen in this commit. The fix is to use the identifier parameter when reading and writing state to/from the PageStorageBucket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions