country_subdivision

Generated ISO 3166-2 country subdivision classes using data from countries.

This package contains subdivision data that was split out of the core country package so applications can depend on it only when administrative division data is required.

Install

dependencies:
  country_subdivision: ^latest_version

pub package

Usage

import 'package:country_subdivision/country_subdivision.dart';

void main() {
  final alaska = CountrySubdivisions.byCode('US', 'AK');
  print(alaska.name); // Alaska

  final usSubdivisions = CountrySubdivisions.byCountry('US');
  print(usSubdivisions.length);
}

Generate data locally

This package is generated from the countries submodule used by the monorepo.

dart run build_runner build --delete-conflicting-outputs

Classes

CountrySubdivision

Parameter Nullable Description
countryCode ISO 3166-1 alpha-2 country code
code ISO 3166-2 subdivision code without country code
fullCode ISO 3166-2 subdivision code with country code
name Subdivision name
unofficialNames Unofficial, slang names or aliases
geo Geographic center and bounds
translations Subdivision name by locale
type Subdivision type, such as state or province

Maintainer

Jack Liu