country_search 2.9.0 copy "country_search: ^2.9.0" to clipboard
country_search: ^2.9.0 copied to clipboard

The Fastest, Most Customizable Country Picker for Flutter.

country_search #

A Flutter country picker with fast search, localization, and flexible UI.

Installation #

dependencies:
  country_search: ^2.9.0

Quick Setup #

import 'package:country_search/country_search.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

MaterialApp(
  localizationsDelegates: const [
    CountryLocalizations.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  supportedLocales: CountryLocalizations.supportedLocales,
  home: const DemoPage(),
)

Use the Builder API for all new code.

CountryPicker.builder()
    .selectedCountry(selectedCountry)
    .onCountrySelected((country) {
      setState(() => selectedCountry = country);
    })
    .build();

Use a single CountryPickerThemeData object instead of many separate style params.

final pickerTheme = CountryPickerThemeData.light.copyWith(
  accentColor: const Color(0xFF1565C0),
  borderRadius: 12,
  itemHeight: 56,
  flagSize: 20,
);

CountryPicker.builder()
    .selectedCountry(selectedCountry)
    .onCountrySelected((country) {
      setState(() => selectedCountry = country);
    })
    .themeData(pickerTheme)
    .modalPresentation(CountryPickerModalPresentation.dialog)
    .showSuggestedCountries(true)
    .build();

Built-in Theme Presets #

  • CountryPickerThemeData.dark
  • CountryPickerThemeData.light
  • CountryPickerThemeData.purple
  • CountryPickerThemeData.minimal

Builder helpers are also available:

  • .darkTheme()
  • .lightTheme()
  • .purpleTheme()
  • .minimalTheme()

Legacy API (Backward Compatible) #

The constructor with individual style fields is still supported for compatibility, but new code should prefer Builder + themeData.

CountryPicker(
  selectedCountry: selectedCountry,
  onCountrySelected: (country) {
    setState(() => selectedCountry = country);
  },
  backgroundColor: Colors.white,
  accentColor: Colors.blue,
)

Search Behavior #

  • Empty query:
    • showSuggestedCountries = true: suggested section + full list.
    • showSuggestedCountries = false: full list.
  • Non-empty query:
    • Search by localized name, ISO code, phone code.
    • Ranking: exact, startsWith, contains, fuzzy.
  • Phone code normalization:
    • +380 and 380 both work.

Country Model #

class Country {
  final String code;      // Example: "US"
  final String flag;      // Example: "πŸ‡ΊπŸ‡Έ"
  final String phoneCode; // Example: "+1"

  String getDisplayName(BuildContext context);
}

Migration #

See MIGRATION.md.

Compatibility #

  • Dart: >=3.0.0 <4.0.0
  • Flutter: >=3.0.0

Development #

flutter analyze
flutter test

License #

MIT. See LICENSE.

1
likes
0
points
678
downloads

Documentation

Documentation

Publisher

verified publisherworldin.net

Weekly Downloads

The Fastest, Most Customizable Country Picker for Flutter.

Repository (GitHub)
View/report issues

Topics

#flags #country #picker #search #phonecodes

License

unknown (license)

Dependencies

flutter, flutter_localizations

More

Packages that depend on country_search