DurationUnit class

The unit of a Duration property written as a plain number.

A Duration property can be written with a unit (30s, 5m) or in ISO-8601 (PT30S). A plain number such as 60 is read as milliseconds unless the field carries this annotation, which makes properties that are naturally in seconds or minutes easy to write. Values with a unit or in ISO-8601 are not affected.

@ConfigurationProperties('app')
class AppProperties {
  @DurationUnit(ChronoUnit.seconds)
  Duration timeout = const Duration(seconds: 30); // app.timeout=60 → 60 s
}

Spring (Java): @DurationUnit(ChronoUnit.SECONDS) private Duration timeout;

Constructors

DurationUnit(ChronoUnit value)
Plain numbers of the field are read in value.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → ChronoUnit
The unit a plain number is read in.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited