DateTimeLoopController constructor

DateTimeLoopController({
  1. required TimeUnit timeUnit,
  2. bool triggerOnStart = true,
  3. DateTime getNow() = DateTime.now,
})

Creates a DateTimeLoopController with the specified timeUnit and triggerOnStart.

Parameters:

  • timeUnit: The interval at which DateTime updates are emitted.
  • triggerOnStart: Whether to emit an initial DateTime when the first listener subscribes.
  • getNow: Optional function to provide the current DateTime. Defaults to DateTime.now. Useful for testing.

Implementation

DateTimeLoopController({
  required this.timeUnit,
  this.triggerOnStart = true,
  this.getNow = DateTime.now,
}) : _streamController = StreamController<DateTime>.broadcast() {
  _initialize();
}