DurationParser class

Parses a duration string into a Duration object.

The input string must be a number followed by an optional unit which is one of: seconds (s), minutes (m), hours (h), days (d), milliseconds (ms), or microseconds (us). If no unit is specified, the defaultUnit is assumed, which is in seconds if not specified otherwise. Examples:

  • 10, equivalent to 10s
  • 10m
  • 10h
  • 10d
  • 10ms
  • 10us

Throws FormatException if parsing failed.

Inheritance

Constructors

DurationParser({DurationUnit defaultUnit = DurationUnit.seconds})
const

Properties

defaultUnit → DurationUnit
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

format(Duration value) → String
Returns a usage documentation friendly string representation of the value. The default implementation simply invokes toString.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String value) → Duration
Converts a source string value to the specific option value type. Must throw a FormatException with an appropriate message if the value cannot be parsed.
override
toString() → String
A string representation of this object.
inherited

Operators

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