syncScrollSubscription method
void
syncScrollSubscription()
Re-points the subscription at the live position when it has been swapped. Idempotent and allocation-free: on the no-swap path it returns after one identity compare. A null live position (unmounted scrollable) detaches without re-attaching.
Implementation
void syncScrollSubscription() {
final listener = _scrollListener;
if (listener == null) {
return;
}
final live = position;
if (identical(live, _subscribedPosition)) {
return;
}
// Safe on a position the scrollable has since disposed and during
// that position's own dispatch: ChangeNotifier.removeListener
// documents both.
_subscribedPosition?.removeListener(listener);
_subscribedPosition = live;
live?.addListener(listener);
}