isBefore method Null safety

bool isBefore(
  1. DateTime other
)

Returns true if this occurs before other.

The comparison is independent of whether the time is in UTC or in the local time zone.

final now = DateTime.now();
final earlier = now.subtract(const Duration(seconds: 5));
print(earlier.isBefore(now)); // true
print(!now.isBefore(now)); // true

// This relation stays the same, even when changing timezones.
print(earlier.isBefore(now.toUtc())); // true
print(earlier.toUtc().isBefore(now)); // true

print(!now.toUtc().isBefore(now)); // true
print(!now.isBefore(now.toUtc())); // true

Implementation

bool isBefore(DateTime other) => _value.isBefore(other);