country_list_picker 1.0.2

CountryListPicker is flutter package for customizable country selection package with multi-languages support.

version version

CountryListPicker is flutter package for customizable country selection package with multi-languages support.

Installation

Run this command:

With Flutter:

 $ flutter pub add country_list_picker

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  country_list_picker: ^1.0.2

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Now in your Dart code, you can use:

import 'package:country_list_picker/country_list_picker.dart'

Usage

import  'package:country_list_picker/country_list_picker.dart';
void  main() {
    //simple code
    CountryListPicker(
          onCountryChanged: ((value) {
              // do something
          }),
          onChanged: (value) {
             // do something
          },
}

Getting started

Supported 250 countries with common/offical name, iso_3166_1_alpha2, iso_3166_1_alpha3, dialing_code, default_number_length, default_number_format, local_number_sample.

Supported languages:

  • Arabic
  • Chinese
  • Croatian
  • Czech
  • English
  • Estonian
  • Finnish
  • French
  • German
  • Hungarian
  • Italian
  • Japanese
  • Korean
  • Persian
  • Polish
  • Portuguese
  • Russian
  • Slovak
  • Spanish
  • Swedish
  • Urdu

Picker Paramters

ParameterTypeDefaultDescription
onCountryChangedValueChanged?nullThis is a callback function that is invoked when the selected country is changed, which can be used to access the newly selected country.
onChangedValueChanged?nullThis is a callback function that is invoked when the phone number in the input field changes, which can be used to access the new phone number.
initialCountryCountriesCountries.EgyptSets the initial country that is selected when the widget is first rendered.
languageLanguagesLanguages.EnglishSets the display language for the widget.
textDirectionTextDirection--Sets the text direction for the widget depending on the language direction.
displayNameNamesNames.commonDetermines whether the country name displayed is common or official.
localCountryCountriesnullRefer to local device which will define by you.
countryNameTextStyleTextStyleTextStyle(fontSize: 15, color: Colors.grey)Text style for the country name display.
isShowFlagbooltrueDetermines the visibility of the flag icon. A value of true will display the flag icon, while a value of false will hide it.
flagSizeSizetruesize of the flag icon. It has a default value Size (40,40)
isShowDiallingCodebooltrueDetermines whether the dialling code should be displayed or not. If true, the dialling code will be displayed. If false, it will be hidden.
isShowDownIconbooltrueDetermines whether the flag icon should be displayed or not. If true, the flag icon will be displayed. If false, it will be hidden.
isShowCountryNamebooltrueDetermines whether the country name should be displayed or not. If true, the country name will be displayed. If false, it will be hidden.
isShowInputFieldbooltrueDetermines whether the phone number input field should be displayed or not. If true, the phone number input field will be displayed. If false, it will be hidden.
iconDownIconIcon(Icons.keyboard_arrow_down, size: 24)Determines whether the dropdown arrow icon should be displayed or not. If true, the dropdown arrow icon will be displayed. If false, it will be hidden.
diallCodeStyleTextStyleTextStyle(fontSize: 16, fontWeight: FontWeight.bold)Text style for the dialling code display.
borderInputBorderUnderlineInputBorder()Border of the phone number input field.
inputThemeInputThemeDataSee Input Paramters sectionTheme data for the phone number input field.
dialogThemeDialogThemeDataSee Dialog Paramters sectionTheme data for the country selection dialog.
    CountryListPicker(
        onCountryChanged: ((value) {
            // do something
        }),
        onChanged: (value) {
            // do something
        },
        initialCountry: Countries.Egypt,
        language: Languages.Arabic,
        isShowDownIcon: picker.isDownIcon,
        isShowCountryTitle: false,   // if you need to hide country title
        displayName: Names.offical,  // if you need to display country offical name
    )

Input Paramters

ParameterTypeDefaultDescription
obscureTextboolfalseDetermines if the text input should be obscured or not.
obscuringCharacterString"*"The character used to obscure the text input.
styleTextStyleTextStyle(fontSize: 16)The text style for the input field.
hintTextStringEnter your phone numberThe hint text to be displayed when the input field is empty.
hintStyleTextStyleTextStyle(fontSize: 16, color: Color(0xFF9E9E9E))text style for the hint text.
borderInputBorderInputBorder.noneThe border style for the input field.
maskString"### #### ###"The mask used to format the text input.

you can set mask and hintString to default value of each country using onCountryChanged.

    String _hintString ="";
    String _mask ="";
    CountryListPicker(
        onCountryChanged: ((value) {
            _hintString = value.local_number_sample;
            _mask = value.default_number_format;lue
            // do something
        }),
        onChanged: (value) {
            // do something
        },
        inputTheme: InputThemeData(
            hintText: _hintString
            hintStyle: input.hintTextStyle,
            border:  InputBorder.UnderlineInputBorder
            mask: _mask,
          ),
    )

Dialog Paramters

ParameterTypeDefaultDescription
isShowFlagboolDetermines whether the flag icon should be displayed. A value of true will display the flag icon, while a value of false will hide it.
isShowDiallCodeboolDetermines whether the dialling code should be displayed. A value of true will display the dialling code, while a value of false will hide it.
isShowFloatButtonboolDetermines whether the floating button should be displayed. A value of true will display the floating button, while a value of false will hide it.
isShowSearchTileboolDetermines whether the search tile should be displayed. A value of true will display the search tile, while a value of false will hide it.
isShowLastPickTileboolDetermines whether the last pick tile should be displayed. A value of true will display the last pick tile, while a value of false will hide it.
isShowAlphabetsBarboolDetermines whether the alphabets bar should be displayed. A value of true will display the alphabets bar, while a value of false will hide it.
backgroundColorColorbackground color for the dialog.
textStyleTextStyletext style for the text displayed in the dialog. The default value is TextStyle(fontSize: 16).
appBarPreferredSizeWidgetAppbar dialog to be displayed on top of the screen.
tileHeightdoubleheight of the tiles. The default value is 50
alphabetsBarThemeAlphabetsBarThemeDatatheme data for the alphabets bar.
tilesThemeTilesThemeDatatheme data for the tiles.
    CountryListPicker(
        onCountryChanged: ((value) {
            // do something
        }),
        onChanged: (value) {
            // do something
        },
        dialogTheme: DialogThemeData(
            isShowFlag: false,          // <- hide dialog flags 
            isShowDialCode: false,      // <- hide dial code 
            isShowFloatButton: false,   // <- hide float button 
            isShowSearchTile: false,    // <- hide search tile 
            isShowLastPickTile: false,  // <- hide last pick tile
            isShowAlphabetsBar: false,  // <- hide alphabets bar 
    )

Alphabets Paramters

ParameterTypeDefaultDescription
backgroundColorColorColors.transparentThe background color of unselected alphabet item
styleTextStyleTextStyle(fontSize: 12)The text style of the alphabet item text.
selectedBackgroundColorColorColors.transparentThe background color of alphabet item.
selectedStyleTextStyleTextStyl(fontSize: 18, fontWeight: FontWeight.bold)The text style of the selected alphabet item text.

Note that: the Country List Picker doesn't support alpabets bar with Chinese, Japanese and Korean languages.

   CountryListPicker(
       onCountryChanged: ((value) {
           // do something
       }),
       onChanged: (value) {
           // do something
       },
       dialogTheme: DialogThemeData(
           alphabetsBarTheme: AlphabetsBarThemeData(
             backgroundColor: Colors.transparent,
             selectedBackgroundColor: Colors.green,  //<- change background of selected item
             // style: ,           // to change unselected alphabet items text style
             // selectedStyle: ,   // to change selected alphabet items text style
           ),
   )

Dialog Tiles Paramters

ParameterTypeDefaultDescription
backgroundColorColorTheme.of(context).colorScheme.surfaceThe background color of the tile.
styleTextStyleTextStyle(fontSize: 16, fontWeight: FontWeight.bold)The text style of the title text.
currentLocationTileTitleString"Current Location"The title of the tile for current location.
lastPickIconIconIcon(Icons.check)The icon for the last pick tile.
lastPickTitleString"Last Pick"The title of the last pick tile.
searchHintString"name/dial code..."The hint text for the search bar.
searchHintStyleTextStyleTextStyle(fontSize: 16, color: Color(0xFF9E9E9E)The text style of the search hint text.
searchTitleString"Search"The title of the search bar.

if you need to show CurrentLocationTile, you must set the localCountry value to country what you want.

Features and bugs

Please file feature requests and bugs at the [issue tracker][tracker]. issue tracker

References.

  1. country_list_pick
  2. getworld]
  3. mask_text_input_formatter