Offset.duration constructor

Offset.duration(
  1. Duration duration
)

Converts the given Duration to an offset, with fractional seconds truncated.

Returns: An offset for the same time as the given time span.

  • RangeError: The given time span falls outside the range of +/- 18 hours.

Implementation

factory Offset.duration(Duration duration) {
  int seconds = duration.inSeconds;
  Preconditions.checkArgumentRange('duration', seconds, _minSeconds, _maxSeconds);
  return Offset(seconds);
}