Currency.number constructor

Currency.number(
  1. int number
)

Find currency by ISO-4217 currency number

Returns UnknownCurrency if fails

Implementation

factory Currency.number(
  /// ISO-4217 number to look for
  int number,
) {
  final info = Iso4217.firstWhere((currency) => currency['number'] == number,
      orElse: () => <String, dynamic>{});

  if (!info.containsKey('code')) return UnknownCurrency(number.toString());

  return Currency(
    info['code'] as String,
    info['number'] as int,
    info['digits'] as int,
  );
}