FakeClock class

A Clock whose time only moves when a test moves it.

Timers scheduled through it fire during advance, in due order, and a callback that schedules another timer inside the window is honoured — so one advance can carry a debounce, the request it triggers, and the backoff that follows.

Unlike wrapping the fetcher in fakeAsync, this leaves the test's own Futures on the real microtask queue, so await still works normally.

Implemented types

Constructors

FakeClock({DateTime? start})
Creates a clock starting at start, or at an arbitrary fixed instant.

Properties

hashCode int
The hash code for this object.
no setterinherited
pendingTimers int
Timers scheduled and not yet fired or cancelled.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

advance(Duration duration) Future<void>
Moves time forward by duration, firing every timer that comes due.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
now() DateTime
The current instant.
override
pumpMicrotasks([int rounds = 8]) Future<void>
Lets already-scheduled microtasks and completed futures run, without moving time.
timer(Duration duration, void callback()) Timer
Schedules callback to run after duration.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited