subtract method

  1. @Possible({RangeError})
  2. @useResult
Offset subtract(
  1. Duration duration
)

Returns a copy of this with the duration subtracted.

Contract

Throws a RangeError if the result is outside the valid range.

Example

Offset(-16).subtract(Duration(hours: 2)); // Offset(-18)

Offset(-18).subtract(Duration(hours: 2)); // throws RangeError

Implementation

@Possible({RangeError})
@useResult Offset subtract(Duration duration) => Offset.fromMicroseconds(_microseconds - duration.inSeconds * 1000 * 1000);