operator - method

Time operator -(
  1. Object? other
)

Subtracts a Duration, Time, or int (ms) from the current instance, returning a new Time instance.

The behavior of the operator depends on the type of other:

  • If other is null, the current instance is returned.
  • If other is an int, it is interpreted as milliseconds and is subtracted from the current instance.
  • If other is a Time or Duration instance, it is subtracted from the current instance.

Throws:

  • A StateError if other is not null, Time, int, or Duration.

Implementation

Time operator -(Object? other) {
  if (other == null) return this;

  var offset = _toOffsetDuration(other);
  if (offset.inMicroseconds == 0) return this;

  return (asDuration - offset).toTime();
}