getUnitByIndex function

Unit? getUnitByIndex(
  1. int? index, [
  2. Unit? def
])

Implementation

Unit? getUnitByIndex(int? index, [Unit? def]) {
  if (index == null || index < 0 || index >= Unit.values.length) return def;
  return Unit.values[index];
}