country_picker_enterprise 1.1.1 copy "country_picker_enterprise: ^1.1.1" to clipboard
country_picker_enterprise: ^1.1.1 copied to clipboard

Enterprise-grade country picker widget for Flutter with multi-language support, phone codes, smart search functionality, and auto country detection.

Country Picker Enterprise #

โš ๏ธ DEPRECATED: This package is no longer maintained. Please use country_search instead.

Why the change? The new country_search package provides:

  • ๐Ÿš€ 4.7x faster search performance (~110 microseconds per query)
  • ๐ŸŒ 10 languages (vs 8 in this package)
  • โšก Lightweight components instead of heavy Material widgets
  • ๐Ÿ“ฑ Weak device optimization for smooth performance on low-end devices
  • ๐ŸŽจ Better UI/UX with modern design patterns
  • ๐Ÿ”ง Active development and regular updates

Migration is easy - the API is very similar. Just replace country_picker_enterprise with country_search in your pubspec.yaml and update your imports.


Enterprise-grade country picker widget for Flutter with multi-language support, phone codes, and automatic country detection.

Demo

Demo Screenshot

โœจ Features #

  • ๐ŸŒ 246 Countries with flags, ISO codes, and phone codes
  • ๐ŸŒ Multi-language Support - English, Spanish, French, German, Portuguese, Russian, Chinese, Arabic with RTL support
  • ๐Ÿ” Smart Search by country name, code, or phone code
  • ๐Ÿ“ž Phone Codes - Complete international dialing codes
  • ๐ŸŒŽ Continent Filtering - Filter countries by continent (North America, South America, Europe, Asia, Africa, Oceania, Antarctica)
  • โญ Popular Countries - Quick access to 8 most popular countries in "All" section
  • ๐ŸŽฏ Auto Country Detection - Automatically detect user's country by IP or locale
  • ๐ŸŽจ 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
  • โšก High Performance - cached data, lazy loading, optimized search

๐Ÿ“Š Comparison with Other Libraries #

Feature country_picker_enterprise flutter_country_picker country_picker country_selector
Countries 246 195 195 195
Languages 8 (EN, ES, FR, DE, PT, RU, ZH, AR) 1 (EN only) 1 (EN only) 1 (EN only)
Phone Codes โœ… Complete โœ… Complete โœ… Complete โœ… Complete
Flags โœ… Emoji flags โœ… Emoji flags โœ… Emoji flags โœ… Emoji flags
Search โœ… Smart search โœ… Basic search โœ… Basic search โœ… Basic search
Continent Filter โœ… 7 continents โŒ โŒ โŒ
Popular Countries โœ… 8 popular countries โŒ โŒ โŒ
Auto Detection โœ… IP + Locale โŒ โŒ โŒ
Performance โœ… Cached data, lazy loading โŒ โŒ โŒ
Customization โœ… High (disable features) โš ๏ธ Medium โš ๏ธ Medium โš ๏ธ Medium
UI Design โœ… Modern & Adaptive โš ๏ธ Basic โš ๏ธ Basic โš ๏ธ Basic
Dependencies Only Flutter SDK Only Flutter SDK Only Flutter SDK Only Flutter SDK
Size โšก Lightweight โšก Lightweight โšก Lightweight โšก Lightweight
Active Development โœ… Yes โš ๏ธ Limited โš ๏ธ Limited โš ๏ธ Limited

Why choose country_picker_enterprise?

  • ๐ŸŒ Most Complete: 246 countries vs 195 in others
  • ๐ŸŒ Multi-Language: 8 languages vs 1 in others (with full RTL support)
  • โญ Popular Countries: Quick access to 8 most popular countries
  • ๐Ÿ” Smart Features: Continent filtering, auto-detection, optimized search
  • โšก High Performance: Cached data, lazy loading, O(1) lookups
  • ๐ŸŽจ Modern UI: Adaptive design for all devices
  • ๐Ÿš€ Simple API: Works out of the box with sensible defaults
  • ๐Ÿ”ง Highly Customizable: Disable any feature you don't need

๐Ÿ“ฆ Installation #

dependencies:
  country_picker_enterprise: ^1.0.0

๐Ÿš€ Usage #

Basic Usage #

import 'package:country_picker_enterprise/country_picker_enterprise.dart';

CountryPicker(
  selectedCountry: selectedCountry,
  onCountrySelected: (Country country) {
    setState(() {
      selectedCountry = country;
    });
  },
)

// That's it! The widget works out of the box with sensible defaults:
// โœ… Auto-detection of user's country
// โœ… Search functionality
// โœ… Continent filtering
// โœ… Popular countries section
// โœ… Phone codes and flags
// โœ… Multi-language support
// โœ… RTL support for Arabic
// โœ… High performance optimizations

Disable Auto Detection #

CountryPicker(
  selectedCountry: selectedCountry,
  onCountrySelected: (Country country) {
    setState(() {
      selectedCountry = country;
    });
  },
  // Disable auto-detection if not needed
  autoDetectCountry: false,
)

Manual Country Detection #

// Detect country by IP address
Country? country = await CountryData.getCountryByIP();

// Detect country by device locale
Country? country = CountryData.getCountryByLocale(Platform.localeName);

// Auto-detect using multiple methods
Country? country = await CountryData.autoDetectCountry();

Chinese Language Example #

// Set up Chinese localization
MaterialApp(
  localizationsDelegates: [
    CountryLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('zh'), // Chinese
  ],
  home: CountryPicker(
    selectedCountry: selectedCountry,
    onCountrySelected: (Country country) {
      setState(() {
        selectedCountry = country;
      });
    },
  ),
)

// Chinese UI will show:
// - "้€‰ๆ‹ฉๅ›ฝๅฎถ" (Select Country)
// - "ๆœ็ดขๅ›ฝๅฎถ..." (Search country...)
// - "้€‰ๆ‹ฉๆ‚จ็š„ๅ›ฝๅฎถ" (Select your country)
// - "็ƒญ้—จ" (Popular)
// - Country names in Chinese (e.g., "ไธญๅ›ฝ", "็พŽๅ›ฝ", "ไฟ„็ฝ—ๆ–ฏ")
// - Continent names in Chinese (e.g., "ไบšๆดฒ", "ๆฌงๆดฒ", "็พŽๆดฒ")

### Arabic Language Example

```dart
// Set up Arabic localization
MaterialApp(
  localizationsDelegates: [
    CountryLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('ar'), // Arabic
  ],
  home: CountryPicker(
    selectedCountry: selectedCountry,
    onCountrySelected: (Country country) {
      setState(() {
        selectedCountry = country;
      });
    },
  ),
)

// Arabic UI will show:
// - "ุงุฎุชุฑ ุงู„ุจู„ุฏ" (Select Country)
// - "ุงู„ุจุญุซ ุนู† ุจู„ุฏ..." (Search country...)
// - "ุงุฎุชุฑ ุจู„ุฏูƒ" (Select your country)
// - "ุดุงุฆุน" (Popular)
// - Country names in Arabic (e.g., "ู…ุตุฑ", "ุงู„ุณุนูˆุฏูŠุฉ", "ุงู„ุฅู…ุงุฑุงุช")
// - Continent names in Arabic (e.g., "ุฃูุฑูŠู‚ูŠุง", "ุขุณูŠุง", "ุฃูˆุฑูˆุจุง")
// - Full RTL (Right-to-Left) support with proper text alignment and icon positioning

Run the Example #

To see the widget in action, run the example app:

cd example
flutter run

๐Ÿงช Testing #

Run tests to verify everything works:

flutter test

Tests cover: widget functionality, auto-detection, all 8 languages, search, and data integrity.

Localization Setup #

With Localization Support

MaterialApp(
  localizationsDelegates: [
    CountryLocalizations.delegate,
    // ... other delegates
  ],
  supportedLocales: [
    const Locale('en'),    // English
    const Locale('es'),    // Spanish
    const Locale('fr'),    // French
    const Locale('de'),    // German
    const Locale('zh'),    // Chinese
    const Locale('ru'),    // Russian
    const Locale('pt'),    // Portuguese
    const Locale('ar'),    // Arabic
  ],
)

Without Localization Setup (Fallback to English)

If you don't add CountryLocalizations.delegate to your localizationsDelegates, the library will automatically fallback to English:

MaterialApp(
  localizationsDelegates: [
    // CountryLocalizations.delegate, // Not added - will fallback to English
    // ... other delegates
  ],
  supportedLocales: [
    const Locale('en'),    // English
    // ... other locales
  ],
)

The library will automatically detect if the delegate is missing and use English as the default language.

Supported Languages #

The library supports 8 languages with complete translations:

  • ๐Ÿ‡บ๐Ÿ‡ธ English - Default language
  • ๐Ÿ‡ช๐Ÿ‡ธ Spanish - Espaรฑol
  • ๐Ÿ‡ซ๐Ÿ‡ท French - Franรงais
  • ๐Ÿ‡ฉ๐Ÿ‡ช German - Deutsch
  • ๐Ÿ‡จ๐Ÿ‡ณ Chinese - ไธญๆ–‡ (Simplified Chinese)
  • ๐Ÿ‡ท๐Ÿ‡บ Russian - ะ ัƒััะบะธะน
  • ๐Ÿ‡ต๐Ÿ‡น Portuguese - Portuguรชs
  • ๐Ÿ‡ธ๐Ÿ‡ฆ Arabic - ุงู„ุนุฑุจูŠุฉ

All country names, UI text, and continent names are fully translated in each supported language.

โ˜• Support the Project #

If you find this library helpful, consider supporting its development:

Buy me a coffee

Your support helps maintain and improve this library! โค๏ธ

๐Ÿ“š API #

CountryPicker #

Parameter Type Description
selectedCountry Country? Selected country
onCountrySelected Function(Country) Callback on selection
enableContinentFilter bool Enable continent filtering (default: true)
enableSearch bool Enable search functionality (default: true)
showPhoneCodes bool Show phone codes in list and selection (default: true)
showFlags bool Show country flags (default: true)
autoDetectCountry bool Auto-detect user's country on initialization (default: true)

Country #

class Country {
  final String code;           // ISO code (e.g., 'US', 'RU')
  final String flag;           // Country flag (e.g., '๐Ÿ‡บ๐Ÿ‡ธ', '๐Ÿ‡ท๐Ÿ‡บ')
  final String phoneCode;      // Phone code (e.g., '+1', '+7')
  final Continent? continent;  // Continent (e.g., Continent.northAmerica, Continent.europe)
}

Continent Filtering #

Filter countries by continent with population-based sorting:

// Get countries by continent
List<Country> europeanCountries = CountryData.getCountriesByContinent(Continent.europe);

// Search by continent name
List<Country> asianCountries = CountryData.searchByContinent('asia');

// Get all available continents (sorted by population)
List<Continent> continents = CountryData.getAvailableContinents();
// Returns: [Continent.asia, Continent.africa, Continent.northAmerica, Continent.southAmerica, Continent.europe, Continent.oceania, Continent.antarctica]

Continent Enum #

enum Continent {
  europe,        // Europe
  asia,          // Asia
  africa,        // Africa
  northAmerica,  // North America
  southAmerica,  // South America
  oceania,       // Oceania
  antarctica,    // Antarctica
}

RTL (Right-to-Left) Support #

The library fully supports RTL languages like Arabic:

// RTL support is automatically enabled for Arabic locale
MaterialApp(
  localizationsDelegates: [
    CountryLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('ar'), // Arabic with RTL support
  ],
)

// RTL features include:
// โœ… Text alignment (right-to-left)
// โœ… Icon positioning (search icon on right, clear on left)
// โœ… Proper text direction for Arabic content
// โœ… Correct arrow direction for dropdown

Get the 8 most popular countries for quick access:

// Get popular countries (US, GB, DE, FR, CA, AU, JP, CN)
List<Country> popularCountries = CountryData.getPopularCountries();

// Popular countries are automatically shown in the "All" section
// when no continent filter is selected and no search is active.
// Popular countries also appear in the main alphabetical list for easy access.
// Note: Popular countries are duplicated in both sections for better UX.
// This ensures users can find popular countries both in the dedicated section
// and in the main alphabetical list.
// Search by code
Country? country = CountryData.getCountryByCode('US');

// Search by phone code
Country? country = CountryData.getCountryByPhoneCode('+1');

// Search by name, code, or phone code
List<Country> results = CountryData.searchCountries(
  'russia',
  (code) => CountryLocalizations.of(context).getCountryName(code)
);

// Search by phone code only
List<Country> results = CountryData.searchByPhoneCode('+1');

// Get countries by continent
List<Country> europeanCountries = CountryData.getCountriesByContinent(Continent.europe);

// Search by continent name
List<Country> results = CountryData.searchByContinent('europe');

// Get all available continents
List<Continent> continents = CountryData.getAvailableContinents();

Performance Optimizations #

The library includes several performance optimizations:

Cached Data

  • Country Lookup: O(1) lookup using cached Map instead of O(n) search
  • Continent Filtering: Pre-built continent-to-countries mapping
  • Search Results: Cached search results per language and query

Lazy Loading

  • ListView Optimization: Only visible items are rendered
  • Memory Efficient: Automatic disposal of off-screen widgets
  • Smooth Scrolling: Optimized ListView with disabled unnecessary features

Search Optimization

  • Indexed Search: Fast search using cached results
  • Language-Aware Caching: Separate cache per language
  • Smart Cache Management: Automatic cache clearing on language change
// Performance optimized methods
List<Country> cachedCountries = CountryData.cachedCountries; // O(1) access
Country? country = CountryData.getCountryByCode('US'); // O(1) lookup
List<Country> europeanCountries = CountryData.getCountriesByContinent(Continent.europe); // O(1) access

// Clear cache when language changes
CountryData.clearSearchCache();

๐Ÿ”ง Customization & Feature Control #

Disable Features (if not needed) #

You can disable any feature using widget parameters:

CountryPicker(
  selectedCountry: selectedCountry,
  onCountrySelected: (Country country) {
    setState(() {
      selectedCountry = country;
    });
  },
  enableSearch: false,           // Disable search functionality
  showPhoneCodes: false,         // Hide phone codes
  showFlags: false,              // Hide country flags
  enableContinentFilter: false,  // Disable continent filtering
)

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
}

Custom Country List #

Create your own country list with only needed countries:

// Custom country list
final myCountries = [
  Country(code: 'US', flag: '๐Ÿ‡บ๐Ÿ‡ธ', phoneCode: '+1'),
  Country(code: 'CA', flag: '๐Ÿ‡จ๐Ÿ‡ฆ', phoneCode: '+1'),
  Country(code: 'GB', flag: '๐Ÿ‡ฌ๐Ÿ‡ง', phoneCode: '+44'),
  // ... only countries you need
];

// Use in your custom picker
List<Country> filteredCountries = myCountries.where((country) => 
  country.code.toLowerCase().contains(query.toLowerCase())
).toList();

Disable Search Functionality #

If you don't need search, create a simple picker:

// Simple country list without search
ListView.builder(
  itemCount: CountryData.countries.length,
  itemBuilder: (context, index) {
    final country = CountryData.countries[index];
    return ListTile(
      leading: Text(country.flag),
      title: Text(CountryLocalizations.of(context).getCountryName(country.code)),
      subtitle: Text(country.code),
      onTap: () => onCountrySelected(country),
    );
  },
)

Custom Display Format #

Control how countries are displayed:

// Custom display without phone codes
ListTile(
  leading: Text(country.flag),
  title: Text(countryName),
  subtitle: Text(country.code), // Only code, no phone
  onTap: () => onCountrySelected(country),
)

// Custom display with only phone codes
ListTile(
  leading: Text(country.flag),
  title: Text(countryName),
  subtitle: Text(country.phoneCode), // Only phone code
  onTap: () => onCountrySelected(country),
)

๐Ÿงช Testing #

flutter test

๐Ÿ“ License #

MIT License - see LICENSE file.

๐Ÿ‘จโ€๐Ÿ’ป Author #

Stanislav Bozhko
Email: stas.bozhko@gmail.com
GitHub: @stanislavworldin
โ˜• Buy me a coffee - Support the project!

1
likes
160
points
12
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

Enterprise-grade country picker widget for Flutter with multi-language support, phone codes, smart search functionality, and auto country detection.

Repository (GitHub)
View/report issues

Topics

#flags #country #picker #search #codes

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on country_picker_enterprise