Dart API Referencedart:isolateTimer

Timer abstract class

abstract class Timer {
  /**
   * Creates a new timer. The [callback] callback is invoked after
   * [milliSeconds] milliseconds.
   */
  factory Timer(int milliSeconds, void callback(Timer timer)) {
    if (_TimerFactory._factory == null) {
      throw new UnsupportedOperationException("Timer interface not supported.");
    }
    return _TimerFactory._factory(milliSeconds, callback, false);
  }

  /**
   * Creates a new repeating timer. The [callback] is invoked every
   * [milliSeconds] millisecond until cancelled.
   */
  factory Timer.repeating(int milliSeconds, void callback(Timer timer)) {
    if (_TimerFactory._factory == null) {
      throw new UnsupportedOperationException("Timer interface not supported.");
    }
    return _TimerFactory._factory(milliSeconds, callback, true);
  }

  /**
   * Cancels the timer.
   */
  void cancel();
}

Constructors

factory Timer(int milliSeconds, void callback(Timer timer)) #

Creates a new timer. The callback callback is invoked after milliSeconds milliseconds.

factory Timer(int milliSeconds, void callback(Timer timer)) {
  if (_TimerFactory._factory == null) {
    throw new UnsupportedOperationException("Timer interface not supported.");
  }
  return _TimerFactory._factory(milliSeconds, callback, false);
}

factory Timer.repeating(int milliSeconds, void callback(Timer timer)) #

Creates a new repeating timer. The callback is invoked every milliSeconds millisecond until cancelled.

factory Timer.repeating(int milliSeconds, void callback(Timer timer)) {
  if (_TimerFactory._factory == null) {
    throw new UnsupportedOperationException("Timer interface not supported.");
  }
  return _TimerFactory._factory(milliSeconds, callback, true);
}

Methods

void cancel() #

Cancels the timer.

void cancel();