systemClock top-level constant

DateTime Function() const systemClock

The production wall-clock time source: DateTime.now.

Use as the default for an injectable DateTime Function() seam:

MyComponent({DateTime Function()? clock}) : clock = clock ?? systemClock;

A test passes its own controllable function instead, so the component never reads real time. This is a const constructor tear-off, so it is free to reference and identical across call sites.

Implementation

const DateTime Function() systemClock = DateTime.now;