millis method
Gets this number as a duration of milliseconds.
Raise IllegalStateException
if the unit is not a duration unit.
Implementation
int millis() {
final u = unit ?? 'null';
if (u == 'ms' || u == 'millisecond') return val.toInt();
if (u == 's' || u == 'sec') return (val * 1000.0).toInt();
if (u == 'min' || u == 'minute') return (val * 1000.0 * 60.0).toInt();
if (u == 'h' || u == 'hr') return (val * 1000.0 * 60.0 * 60.0).toInt();
throw FormatException('Invalid duration unit: $u');
}