country_search 2.2.0
country_search: ^2.2.0 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, Portuguese, Russian
- π 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
π± Screenshots #
Country Search Demo #

π¦ Installation #
dependencies:
country_search: ^2.1.1
π 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 (6 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
- π΅πΉ Portuguese
π§ͺ 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! β