country_search 2.2.2
country_search: ^2.2.2 copied to clipboard
A beautiful and customizable country picker widget for Flutter with multi-language support, phone codes, and smart search functionality.
Country Search #
A beautiful and customizable country picker widget for Flutter with multi-language support and phone codes.
๐ฆ Package Size: 96KB - Zero external dependencies
โจ Features #
- ๐ 246 Countries with flags, ISO codes, and phone codes
- ๐ Multi-language Support - English, Spanish, French, German, Italian, Japanese, Portuguese, Russian, Chinese
- ๐ Smart Search by country name, code, or phone code
- ๐ Phone Codes - Complete international dialing codes
- ๐จ Adaptive Design for mobile, tablet and desktop
- โก Lightweight - only Flutter SDK
- ๐ง Highly Customizable - easily disable unwanted features
- ๐ Cross-Platform - works on mobile, web, and desktop

๐ฆ Installation #
dependencies:
country_search: ^2.2.0
๐ Usage #
Basic Usage (English by default) #
import 'package:country_search/country_search.dart';
CountryPicker(
selectedCountry: selectedCountry,
onCountrySelected: (Country country) {
setState(() {
selectedCountry = country;
});
debugPrint('Selected: ${country.flag} ${country.code} (${country.phoneCode})');
},
showPhoneCodes: true, // Show phone codes (default)
)
โ Works immediately without any setup! The widget uses English by default.
Run the Example #
To see the widget in action, run the example app:
cd example
flutter run
The example demonstrates:
- โ Multi-language support (9 languages)
- โ Country search by name, code, and phone code
- โ Beautiful dark theme UI
- โ Responsive design for all screen sizes
๐ง Customization #
Show/Hide Phone Codes #
Control whether phone codes are displayed in the country list:
// Show phone codes (default)
CountryPicker(
selectedCountry: selectedCountry,
onCountrySelected: (Country country) {
setState(() {
selectedCountry = country;
});
},
showPhoneCodes: true, // Default behavior
)
Multi-Language Support #
The widget works with English by default. For multi-language support, add delegates to your MaterialApp:
// If you don't have delegates yet:
MaterialApp(
localizationsDelegates: CountrySearchDelegates.allDelegates,
supportedLocales: CountrySearchDelegates.supportedLocales,
// ... rest of your app
)
// If you already have delegates, add ours:
MaterialApp(
localizationsDelegates: [
// Your existing delegates
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
// Add our delegate
CountryLocalizations.delegate,
],
supportedLocales: [
// Your existing locales
const Locale('en'),
const Locale('de')
],
)
Disable Phone Codes (Optional) #
If you don't need phone codes, you can disable them using the showPhoneCodes parameter:
CountryPicker(
selectedCountry: selectedCountry,
onCountrySelected: (Country country) {
setState(() {
selectedCountry = country;
});
debugPrint('Selected: ${country.flag} ${country.code}');
},
showPhoneCodes: false, // Disable phone codes display
)
Remove Unused Languages #
To reduce package size, remove language files you don't need:
# Remove unused language files
rm lib/src/flutter_country_picker/localizations/country_localizations_es.dart
rm lib/src/flutter_country_picker/localizations/country_localizations_fr.dart
rm lib/src/flutter_country_picker/localizations/country_localizations_ru.dart
Then update country_localizations.dart:
CountryLocalizations lookupCountryLocalizations(Locale locale) {
switch (locale.languageCode) {
case 'en':
return CountryLocalizationsEn();
// Remove cases for deleted languages
// case 'es': return CountryLocalizationsEs();
// case 'fr': return CountryLocalizationsFr();
// case 'ru': return CountryLocalizationsRu();
}
return CountryLocalizationsEn(); // Fallback to English
}
๐ Supported Languages #
- ๐บ๐ธ English
- ๐ท๐บ Russian
- ๐ช๐ธ Spanish
- ๐ซ๐ท French
- ๐ฉ๐ช German
- ๐ฎ๐น Italian
- ๐ฏ๐ต Japanese
- ๐ต๐น Portuguese
- ๐จ๐ณ Chinese
๐งช Testing #
flutter test
๐ License #
MIT License - see LICENSE file.
๐จโ๐ป Author #
Stanislav Bozhko
Email: [email protected]
GitHub: @stanislavworldin
โ Support #
If you find this package helpful, consider buying me a coffee! โ