mi_country_picker 0.0.6

SDKflutter
Platformandroidioswindowslinuxmacosweb

Flutter package for selecting country codes. Offers multiple modes for picker and supports locale in 70 languages.

mi_country_picker

A Flutter package for selecting country codes from a list. It offers multiple modes for the country code picker and supports the locale of the current device in 70 different languages.

Overview

localization support

Example

For Country picker dialog

final country= await CountryPicker.showCountryPickerDialog(context: context);

For Country picker bottom sheet

final country= await CountryPicker.showCountryPickerBottomSheet(context: context);

For Country picker cupertino bottom sheet

final country = await CountryPicker.showCountryPickerCupertinoBottomSheet(context: context);

For the Country picker dropdown

CountryPickerDropDown(
      onSelectValue: (CountryData value) {
        debugPrint('CountryPickerDropDown ::${value.name}');
      },
    );

get the initial country with CountryPicker.getCountryData.

CountryPicker.getCountryData(context: context,code: "IN"); 

For localization

Add the CountryPickerLocalizations.delegate to the list of your app delegates.

return MaterialApp(
    supportedLocales: [
        Locale("hi"),
        Locale("tk"),
        Locale("uk"),
        ...
        ...
        ...
        Locale("zh")
      ],
      localizationsDelegates: [
        CountryPickerLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
);

CountryPicker

The CountryPicker class encapsulates all functionalities of this package. Utilize these optional properties to customize the appearance and view of the picker according to your preferences.

FieldsTypeDescription
contextBuildContextA handle to the location of a widget in the widget tree Required.
favouriteCountriesList<String>?favouriteCountries will be placed on the top of list.
barrierColorColor?barrierColor that covers the screen behind a modal or overlay widget.
isDismissiblebool?isDismissible determines whether the widget can be dismissed or closed by tapping outside of it.
backgroundColorColor?backgroundColor is a property to set the background color of the country picker widget.
useSafeAreabool?useSafeArea is for visible/avoids overlapping with system UI elements.

LayoutConfig and SearchStyle models are used to configure the layout and styling of the interface.

FieldsTypeDescription
textStyleTextStyle?to set the Style for country list elements.
elementsSequenceSequenceTo set the Sequence of countries elements by default it is Sequence.codeCountryNameAndFlag.
flagWidthboolset width of the flag by default is 24.
flagHeightboolset height of the flag by default is 18.
flagDecorationDecoration?set decoration of the flag.
showCountryNameboolshow/hide country name by default is true.
showCountryFlagboolshow/hide country flag by default it's true.
showCountryCodeboolshow/hide country code by default it's true.
searchFieldInputDecorationInputDecoration?to decorate or customize the country flag.
searchFieldInputDecorationInputDecoration?to decorate or customize the country flag.
hintTextString?give the hint in searchBar.
searchBoxHeightdouble?set the height of search bar.
searchBoxHeightdouble?set the height of search bar.
searchBoxMarginEdgeInsetsGeometry?set the margin of SearchBox.

CountryListConfig model is used to manipulate the country list.

FieldsTypeDescription
countryFilterList<String>?Provide the list of countries country code to show the list of countries in Country picker.
comparatorComparator<CountryData>?comparator is used to change the order of country list.
excludeCountryList<String>??remove particular countries from our list.

Guideline for contributors

Contribution towards our repository is always welcome, we request contributors to create a pull request to the develop branch only.

Guideline to report an issue/feature request

It would be great for us if the reporter could share the below things to understand the root cause of the issue.

  • Library version
  • Code snippet
  • Logs if applicable
  • Device specification like (Manufacturer, OS version, etc)
  • Screenshot/video with steps to reproduce the issue

LICENSE!

mi_country_picker is MIT-licensed.

Let us know!

We’d be really happy if you send us links to your projects where you use our component. Just send an email to sales@mindinventory.com And do let us know if you have any questions or suggestions regarding our work.