fakeAsync<T> function

T fakeAsync<T>(
  1. T callback(
    1. FakeAsync async
  2. {DateTime? initialTime}

Runs callback in a Zone where all asynchrony is controlled by an instance of FakeAsync.

All Futures, Streams, Timers, microtasks, and other time-based asynchronous features used within callback are controlled by calls to FakeAsync.elapse rather than the passing of real time.

The clock property will be set to a clock that reports the fake elapsed time. By default, it starts at the time fakeAsync was created (according to clock.now()), but this can be controlled by passing initialTime.

Returns the result of callback.


T fakeAsync<T>(T Function(FakeAsync async) callback, {DateTime? initialTime}) =>
    FakeAsync(initialTime: initialTime).run(callback);