For 122 languages
- Country code to name mappings.
- Locale code to name mappings.
This is a port of an npm package localized-countries for Flutter.
Data is taken from https://github.com/umpirsky/country-list and https://github.com/umpirsky/locale-list.
This package bundles required assets and provides custom LocalizationsDelegates for loading them.
import 'package:flutter_localized_countries/flutter_localized_countries.dart';
void main() {
runApp(MaterialApp(
localizationsDelegates: [
CountryNamesLocalizationsDelegate(),
// ... more localization delegates
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
...
);
...
print(CountryNames.of(context).nameOf('NL')); // Netherlands;
}
import 'package:flutter_localized_countries/flutter_localized_countries.dart';
void main() {
runApp(MaterialApp(
localizationsDelegates: [
LocaleNamesLocalizationsDelegate(),
// ... more localization delegates
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
...
);
...
print(LocaleNames.of(context).nameOf('en_GB')); // English (United Kingdom)
}
- Sorting by name does not respect the locale, because Flutter does not provide any API for string collation.