stream static method
Emits a continuous stream of accurate DateTime values at interval.
Ideal for live clocks, auction timers, and TOTP countdowns. Automatically triggers background resynchronization if the cache expires or if system clock tampering is detected.
Implementation
static Stream<DateTime> stream({
Duration interval = const Duration(seconds: 1),
bool isUtc = false,
NtpServer server = NtpServer.google,
String? customServer,
int port = 123,
int timeout = 5,
}) async* {
yield await now(
isUtc: isUtc,
server: server,
customServer: customServer,
port: port,
timeout: timeout,
);
yield* Stream.periodic(interval, (_) {
return nowSync(
isUtc: isUtc,
server: server,
customServer: customServer,
port: port,
timeout: timeout,
);
});
}