Skip to main content
A Duration in Dart is an immutable class representing a continuous span of time. It measures a relative time interval independent of any specific calendar date, time zone, or clock. Internally, Dart normalizes and stores all Duration instances as a single integer value of microseconds.

Instantiation

The Duration constructor accepts named, optional integer arguments. Because the class normalizes the input into a single microsecond integer, arguments can be negative or exceed standard time boundaries (e.g., passing 90 minutes is perfectly valid and evaluates to 1 hour and 30 minutes).

Property Accessors

Duration provides getter properties to extract the time span. These properties return the total duration truncated to the requested unit, rather than the isolated component passed to the constructor.

Arithmetic Operators

Duration supports operator overloading for standard arithmetic, allowing direct mathematical operations between Duration instances or between a Duration and a numeric scalar.

Relational Operators

Because Duration implements Comparable<Duration>, instances can be compared using standard relational operators. Comparisons are evaluated based on the underlying microsecond integer.

Core Methods

Duration exposes utility methods for absolute value conversion and explicit comparison.
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More