getByCode static method

CountryModel getByCode(
  1. String code
)

Resolve by ISO 3166-1 alpha-2 (e.g. BD, US). Falls back to United States.

Implementation

static CountryModel getByCode(String code) {
  final c = _service.findByCode(code.toUpperCase());
  if (c != null) return fromCountry(c);
  final fallback = _service.findByCode('US');
  return fromCountry(fallback!);
}