elapse method Null safety
- Duration duration
Simulates the asynchronous passage of time.
Throws an ArgumentError if duration
is negative. Throws a StateError
if a previous call to elapse has not yet completed.
Any timers created within run or fakeAsync will fire if their time is
within duration
. The microtask queue is processed before and after each
timer fires.
Implementation
void elapse(Duration duration) {
if (duration.inMicroseconds < 0) {
throw ArgumentError.value(duration, 'duration', 'may not be negative');
} else if (_elapsingTo != null) {
throw StateError('Cannot elapse until previous elapse is complete.');
}
_elapsingTo = _elapsed + duration;
_fireTimersWhile((next) => next._nextCall <= _elapsingTo!);
_elapseTo(_elapsingTo!);
_elapsingTo = null;
}