PausableTimer constructor

PausableTimer(
  1. Duration duration,
  2. void callback()
)

Creates a new timer.

The callback is invoked after the given duration, but can be paused in between or reset. The elapsed time is only accounted for while the timer isActive.

The timer isPaused when created, and must be started manually.

The duration must be equals or bigger than Duration.zero. If it is Duration.zero, the callback will still not be called until the timer is started.

Implementation

PausableTimer(Duration duration, void Function() callback)
    : assert(duration >= Duration.zero),
      _originalDuration = duration,
      _zone = Zone.current {
  _callback = _zone.bindCallback(callback);
  assert(_callback != null);
}