PausableTimer constructor

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

Creates a new pausable 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 is active.

The timer is paused 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(this.duration, void Function() callback)
    : assert(duration >= Duration.zero),
      _zone = Zone.current,
      _periodic = false {
  _callback = _zone.bindCallback(callback);
}