keepScrollOffset property

bool keepScrollOffset
final

Each time a scroll completes, save the current scroll offset with PageStorage and restore it if this controller's scrollable is recreated.

If this property is set to false, the scroll offset is never saved and initialScrollOffset is always used to initialize the scroll offset. If true (the default), the initial scroll offset is used the first time the controller's scrollable is created, since there's no scroll offset to restore yet. Subsequently the saved offset is restored and initialScrollOffset is ignored.

See also:

  • PageStorageKey, which should be used when more than one scrollable appears in the same route, to distinguish the PageStorage locations used to save scroll offsets.

Implementation

final bool keepScrollOffset;