isBefore method

bool isBefore(
  1. LocalDateTime other
)

Returns true if this instance is earlier than other.

Example:

final dt1 = LocalDateTime.of(2024, 6, 27, 14, 30);
final dt2 = LocalDateTime.of(2024, 6, 27, 15, 30);
print(dt1.isBefore(dt2)); // true
print(dt2.isBefore(dt1)); // false

Implementation

bool isBefore(LocalDateTime other) => compareTo(other).isLessThan(0);