country_search 2.2.3 copy "country_search: ^2.2.3" to clipboard
country_search: ^2.2.3 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

Demo

๐Ÿ“ฆ 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! โ˜•

ko-fi

1
likes
0
points
53
downloads

Publisher

verified publisherworldin.net

Weekly Downloads

A beautiful and customizable country picker widget for Flutter with multi-language support, phone codes, and smart search functionality.

Repository (GitHub)
View/report issues

Topics

#flags #country #picker #search #phone-codes

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, flutter_localizations

More

Packages that depend on country_search