Published 2026-08-29
copied due to outdated dependencies.
Countries, codes, flags and several way of picking them at your service...one widget away...

CountryPickerDropdown(
initialValue: 'AR',
itemBuilder: _buildDropdownItem,
itemFilter: ['AR', 'DE', 'GB', 'CN'].contains(c.isoCode),
priorityList:[
CountryPickerUtils.getCountryByIsoCode('GB'),
CountryPickerUtils.getCountryByIsoCode('CN'),
],
sortComparator: (Country a, Country b) => a.isoCode.compareTo(b.isoCode),
onValuePicked: (Country country) {
print("${country.name}");
},
)
Widget _buildDropdownItem(Country country) => Container(
child: Row(
children: <Widget>[
CountryPickerUtils.getDefaultFlagImage(country),
SizedBox(
width: 8.0,
),
Text("+${country.phoneCode}(${country.isoCode})"),
],
),
);
void _openCountryPickerDialog() => showDialog(
context: context,
builder: (context) => Theme(
data: Theme.of(context).copyWith(primaryColor: Colors.pink),
child: CountryPickerDialog(
titlePadding: EdgeInsets.all(8.0),
searchCursorColor: Colors.pinkAccent,
searchInputDecoration: InputDecoration(hintText: 'Search...'),
isSearchable: true,
title: Text('Select your phone code'),
onValuePicked: (Country country) =>
setState(() => _selectedDialogCountry = country),
itemFilter: (c) => ['AR', 'DE', 'GB', 'CN'].contains(c.isoCode),
priorityList: [
CountryPickerUtils.getCountryByIsoCode('TR'),
CountryPickerUtils.getCountryByIsoCode('US'),
],
itemBuilder: _buildDialogItem)),
);
void _openCupertinoCountryPicker() => showCupertinoModalPopup<void>(
context: context,
builder: (BuildContext context) {
return CountryPickerCupertino(
pickerSheetHeight: 300.0,
onValuePicked: (Country country) =>
setState(() => _selectedCupertinoCountry = country),
itemFilter: (c) => ['AR', 'DE', 'GB', 'CN'].contains(c.isoCode),
priorityList: [
CountryPickerUtils.getCountryByIsoCode('TR'),
CountryPickerUtils.getCountryByIsoCode('US'),
],
);
});
Thanks goes to country-flags repo for the flag image assets.
Thanks @phamnhuvu-dev, @shadyshrif, @Tan-JamickoJohn
Fix issue #10 Thanks @ened
BREAKING CHANGE: CountryPickerDropdown has more customization fields. isDense defaults to false.
getCountryByName and getCountryByIso3Code is added to CountryPickerUtils class. PR #28 PR #29 Thanks @leynier
searchFilter property is added to CountryPickerDialog PR #30 Thanks @leynier
Add features(priority list and sort by field) requested in issue #14 Thanks @muarifer and @ziyan-junaideen
Add isExpanded property to CountryPickerDropdown PR #22 Thanks @Pradeepkn
Add popOnPick property to CountryPickerDialog PR 24 Thanks @crtl
Fix issue #12 - Fix background color setting for CountryPickerCupertino. Thanks @rhmoeller
Fix filtering issue for CountryPickerCupertino.
Fix Update for iPhone X UI issues with safe-area. PR #13 Thanks @dhavalagile