Time.now constructor

Time.now()

Creates a Time representing the current time in UTC, using Zone-provided time if available.

Note: you can mock the current Time by setting the nowKey in the Zone to a valid Now function that returns a UTC DateTime.

The resulting Time will always be in UTC.

Implementation

factory Time.now() => switch (Zone.current[nowKey]) {
      final Now now => Time(now().toUtc()),
      _ => Time(_utcNow),
    };