getByKey method

int? getByKey(
  1. String key
)

Gets a component by name.

Returns null if the key is not recognized.

Implementation

int? getByKey(String key) => switch (key.toLowerCase()) {
      'year' || 'years' => year,
      'month' || 'months' => month,
      'day' || 'days' || 'date' => day,
      'hour' || 'hours' => hour,
      'minute' || 'minutes' => minute,
      'second' || 'seconds' => second,
      'millisecond' || 'milliseconds' => millisecond,
      'microsecond' || 'microseconds' => microsecond,
      'weekday' => weekday,
      'quarter' || 'quarters' => quarter,
      'dayofyear' => dayOfYear,
      'isoweek' => isoWeek,
      'isoweekyear' => isoWeekYear,
      _ => null,
    };