countries_utils 2.0.0
countries_utils: ^2.0.0 copied to clipboard
A lightweight pure-Dart package for offline world countries data with query utilities.
Changelog #
2.0.0 — 2026-03-23 #
Major release. Full Dart 3 modernization, immutable models via freezed, automated data sync pipeline, and a null-safe query API. Not backwards-compatible with 1.x.
Breaking Changes #
| 1.x | 2.0.0 |
|---|---|
country.currnecies |
country.currencies (typo fixed) |
country.fromJosn() |
country.fromJson() (typo fixed, generated) |
Countries.byCode() returns Country (throws on miss) |
Returns Country? (null-safe) |
Countries.byName() returns Country (throws on miss) |
Returns Country? |
Countries.byRegion(String) |
Countries.byRegion(Region) — takes enum |
Countries.byCallingCode(String) |
Countries.byDialCode(String) |
CountryList, CurrencyList, TimeZoneList wrapper classes |
Plain List<Country>, List<Currency>, etc. |
country.region is String? |
country.region is Region enum |
country.latitude / country.longitude |
country.coordinates?.lat / country.coordinates?.lng (record) |
country.timeZones is List<String> |
country.timeZones is List<TimeZone> |
Migration Guide #
// 1.x
final country = Countries.byCode('US'); // throws if not found
print(country.currnecies?.currencies?.first?.name);
Countries.byRegion('Asia');
Countries.byCallingCode('93');
// 2.0.0
final country = Countries.byCode('US'); // returns null if not found
print(country?.currencies.first.name);
Countries.byRegion(Region.asia);
Countries.byDialCode('93');
New Features #
- Dart 3 — SDK constraint
>=3.4.0 <4.0.0, full null-safety freezedmodels — immutableCountry,Currency,Language,TimeZonewith value equality,copyWith, andtoStringRegionenum —africa,americas,antarctic,asia,europe,oceania,unknownwithdisplayNameCountry.coordinates— Dart record({double lat, double lng})?replacing separate lat/lng fieldsCountry.flagIcon— derived flag emoji fromalpha2Code, no extra fieldCountry.translate(String isoCode)— returns translated name for ISO 639-3 language code- New query methods on
Countries:Countries.search(String query)— fuzzy match on name, nativeName, altSpellings, capitalCountries.withCurrency(String code)— filter by ISO 4217 currency codeCountries.withLanguage(String code)— filter by ISO 639-3 language codeCountries.withDialCode(String code)— filter by calling code prefixCountries.landlocked()— all landlocked countriesCountries.bordersOf(String alpha3)— countries bordering a given alpha-3 codeCountries.currencies()— all uniqueCurrencyobjectsCountries.languages()— all uniqueLanguageobjectsCountries.byAlpha3Code(String),Countries.byNumericCode(String),Countries.byFlag(String),Countries.byCapital(String)
CountryListXextension — fluent query methods onList<Country>:byRegion,search,withCurrency,withLanguage,withDialCode,borderingCountries,areaBiggerThan,areaSmallerThan,unMembers,independent,landlocked,sortedByName,sortedByArea,byCode- Data sync pipeline —
dart tool/fetch_countries.dartregenerateslib/countries_data.dartfrom REST Countries API v3.1; seeMakefile
Internal Changes #
- Data now sourced from REST Countries API v3.1 — fetched in 3 batched requests merged by
cca2 lib/countries_data.dartis generated, not manually maintained (gitignored)- Deleted
lib/models/country_list.dart,currency_list.dart,timezone_list.dart - Restructured
lib/tolib/src/models/andlib/src/extensions/
1.0.1 #
- updated library name and file structures
- added dart docs support and generated docs
- enhanced comments for library and functions
- fixed test package in dependencies
1.0.0 #
- migrated to null safety
- fixed typos and improved stability
- made the package pure dart with no flutter dependencies
- migrated from old package flutter_country to countries_utils
0.1.1 #
- added Arabic Country names
- added new translate() method
- added timeZone() method
- added byTimeStamp method and test
0.1.0 #
- changed countries data to use restcountries data
- refactored methods to work with new sets
- removed unused methods and models
0.0.4 #
- fixed calling codes double xx in some countries
0.0.3 #
- removed flutter dependency, package now supports plain dart
- fixed bug with native name translation not found
- fixed typos
0.0.1 #
- initial release