setByKey method

Hora setByKey(
  1. String key,
  2. int value
)

Sets a component by name.

Returns this instance if the key is not recognized.

Implementation

Hora setByKey(String key, int value) => switch (key.toLowerCase()) {
      'year' || 'years' => copyWith(year: value),
      'month' || 'months' => copyWith(month: value),
      'day' || 'days' || 'date' => copyWith(day: value),
      'hour' || 'hours' => copyWith(hour: value),
      'minute' || 'minutes' => copyWith(minute: value),
      'second' || 'seconds' => copyWith(second: value),
      'millisecond' || 'milliseconds' => copyWith(millisecond: value),
      'microsecond' || 'microseconds' => copyWith(microsecond: value),
      _ => this,
    };