DurationConverter class
Converts arbitrary values into Date values using extended conversion rules:
- Strings: converted using ISO time format
- Numbers: converted using milliseconds since unix epoch
Example
var value1 = DurationConverter.toNullableDuration('ABC'); // Result: null
var value2 = DurationConverter.toNullableDuration('123'); // Result: Duration(milliseconds: 123)
var value3 = DurationConverter.toNullableDuration(123); // Result: Duration(milliseconds: 123)
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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
Static Methods
-
toDuration(
dynamic value) → Duration - Converts value into Date or returns current date when conversion is not possible.
-
toDurationWithDefault(
dynamic value, Duration defaultValue) → Duration - Converts value into Date or returns default when conversion is not possible.
-
toNullableDuration(
dynamic value) → Duration? - Converts value into Date or returns null when conversion is not possible.