API Reference

Detailed documentation of the country_names package API.

CountryListView

The main widget for displaying a list of countries.

Constructor

const CountryListView({
  Key? key,
  void Function(InternalCountry country)? onSelect,
  CountryItemBuilder? itemBuilder,
  OrderBy sortBy = OrderBy.name,
  ImageQuality quality = ImageQuality.small,
})

Properties

PropertyTypeDescription
onSelectvoid Function(InternalCountry country)?Callback function called when a country is selected
itemBuilderCountryItemBuilder?Function to build custom country list items
sortByOrderByDetermines how countries are sorted (by name or code)
qualityImageQualityDetermines the quality of flag images (small or high)

Country

Class representing a country with its name, code, and flag.

Constructor

const Country({
  required this.name,
  required this.code,
  required this.flag,
})

Properties

PropertyTypeDescription
nameStringThe name of the country
codeStringThe ISO 3166-1 alpha-2 code of the country
flagStringThe path to the flag image asset

Enums

OrderBy

Enum for specifying the sort order of countries.

ValueDescription
nameSort countries alphabetically by name
codeSort countries alphabetically by country code

ImageQuality

Enum for specifying the quality of flag images.

ValueDescription
smallUse smaller flag images (80px)
highUse higher quality flag images (160px)

TypeDefs

CountryItemBuilder

Function type for building custom country list items.

typedef CountryItemBuilder = Widget Function(BuildContext context, InternalCountry country);