getCountryData static method

CountryData? getCountryData(
  1. int id
)

Returns country metadata for the supplied country ID.

Parameters

  • id: (int) Internal country identifier.

Returns

  • (CountryData?) A CountryData instance when available, otherwise null.

Implementation

static CountryData? getCountryData(final int id) {
  final OperationResult resultString = staticMethod(
    'MapDetails',
    'getCountryData',
    args: id,
  );

  if (resultString['gemApiError'] != 0) {
    return null;
  }

  if (resultString['result']['image'] == -1) {
    return CountryData(
      name: resultString['result']['name'],
      isoCode: resultString['result']['iso'],
    );
  }

  final Img image = Img.init(resultString['result']['image']);

  return CountryData(
    name: resultString['result']['name'],
    isoCode: resultString['result']['iso'],
    flagImage: image,
  );
}