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

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! β˜•

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