saveOffset method Null safety

  1. @override
void saveOffset(
  1. double offset
)
override

Called by the ScrollPosition whenever scrolling ends to persist the provided scroll offset for state restoration purposes.

The ScrollContext may pass the value back to a ScrollPosition by calling ScrollPosition.restoreOffset at a later point in time or after the application has restarted to restore the scroll offset.

Implementation

@override
void saveOffset(double offset) {
  assert(debugIsSerializableForRestoration(offset));
  _persistedScrollOffset.value = offset;
  // [saveOffset] is called after a scrolling ends and it is usually not
  // followed by a frame. Therefore, manually flush restoration data.
  ServicesBinding.instance.restorationManager.flushData();
}