absorbTicker method Null safety

void absorbTicker(
  1. Ticker originalTicker
)

Makes this Ticker take the state of another ticker, and disposes the other ticker.

This is useful if an object with a Ticker is given a new TickerProvider but needs to maintain continuity. In particular, this maintains the identity of the TickerFuture returned by the start function of the original Ticker if the original ticker is active.

This ticker must not be active when this method is called.

Implementation

void absorbTicker(Ticker originalTicker) {
  assert(!isActive);
  assert(_future == null);
  assert(_startTime == null);
  assert(_animationId == null);
  assert((originalTicker._future == null) == (originalTicker._startTime == null), 'Cannot absorb Ticker after it has been disposed.');
  if (originalTicker._future != null) {
    _future = originalTicker._future;
    _startTime = originalTicker._startTime;
    if (shouldScheduleTick) {
      scheduleTick();
    }
    originalTicker._future = null; // so that it doesn't get disposed when we dispose of originalTicker
    originalTicker.unscheduleTick();
  }
  originalTicker.dispose();
}