start method Null safety

TickerFuture start ()

Starts the clock for this Ticker. If the ticker is not muted, then this also starts calling the ticker's callback once per animation frame.

The returned future resolves once the ticker stops ticking. If the ticker is disposed, the future does not resolve. A derivative future is available from the returned TickerFuture object that resolves with an error in that case, via TickerFuture.orCancel.

Calling this sets isActive to true.

This method cannot be called while the ticker is active. To restart the ticker, first stop it.

By convention, this method is used by the object that receives the ticks (as opposed to the TickerProvider which created the ticker).


TickerFuture start() {
  assert(() {
    if (isActive) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('A ticker was started twice.'),
        ErrorDescription('A ticker that is already active cannot be started again without first stopping it.'),
        describeForError('The affected ticker was'),
    return true;
  assert(_startTime == null);
  _future = TickerFuture._();
  if (shouldScheduleTick) {
  if (SchedulerBinding.instance!.schedulerPhase.index > SchedulerPhase.idle.index &&
      SchedulerBinding.instance!.schedulerPhase.index < SchedulerPhase.postFrameCallbacks.index)
    _startTime = SchedulerBinding.instance!.currentFrameTimeStamp;
  return _future!;