parse static method

Converter? parse(
  1. String id, {
  2. Converter? orElse,
})

Returns the Converter for this id or null if there is no Converter associated with this id.

Implementation

static Converter? parse(String id, {Converter? orElse}) {
  try {
    return Units.values.firstWhere((unit) => unit.id == id);
  } on StateError {
    if (orElse != null) {
      return orElse;
    } else {
      rethrow;
    }
  }
}