getAlternativeUnits method

List<UnitOfMeasuresDto> getAlternativeUnits(
  1. UnitOfMeasures unitOfMeasures
)

Implementation

List<UnitOfMeasuresDto> getAlternativeUnits(UnitOfMeasures unitOfMeasures) {
  return unitOfMeasures.results
      .where((unitData) => unitData.altUnit.isNotNullOrEmpty)
      .map((unitData) {
        try {
          return UnitOfMeasuresDto(
            unit: unitData.altUnit ?? '',
            numerator: double.parse(unitData.numerator!),
            denominator: double.parse(unitData.denominatr!),
          );
        } catch (_) {
          return null;
        }
      })
      .whereType<UnitOfMeasuresDto>()
      .toList();
}