A Flutter Country Picker Widget with support to country dialing codes

Overview

Pub

flutter_country_picker

A Flutter Country Picker Widget with support to country dialing codes

Usage

Add the CountryPicker widget in your layout and use the onChanged callback.
Full example

///full Great Britain sample.
///static const Country GB = Country(
///    asset: "assets/flags/gb_flag.png",
///    dialingCode: "44",
///    isoCode: "GB",
///    name: "United Kingdom",
///    currency: "British pound",
///    currencyISO: "GBP",
///  );


 @override
 Widget build(BuildContext context) {
   return new Scaffold(
     appBar: new AppBar(
       title: Text('Flutter Country Picker Demo'),
     ),
     body: new Center(
       child: CountryPicker(
         dense: false,
         showFlag: true,  //displays flag, true by default
         showDialingCode: false, //displays dialing code, false by default
         showName: true, //displays country name, true by default
         showCurrency: false, //eg. 'British pound'
         showCurrencyISO: true, //eg. 'GBP'
         onChanged: (Country country) {
           setState(() {
             _selected = country;
           });
         },
         selectedCountry: _selected,
       ),
     ),
   );
 }
Comments
  • Unsupported Swift Version

    Unsupported Swift Version

    Can't build ios with this error:

    The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

    If I open the project in ios, the error is:

    The target “flutter_country_picker” contains source code developed with Swift 2.x. Xcode 9 does not support building or migrating Swift 2.x targets.

    Use Xcode 8.x to migrate the code to Swift 3.

    question 
    opened by LiveRock 4
  • Error: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.2.51 and higher. Project 'flutter_country_picker' is using version 1.2.30.

    Error: The Android Gradle plugin supports only Kotlin Gradle plugin version 1.2.51 and higher. Project 'flutter_country_picker' is using version 1.2.30.

    I am using Android studio 3.2. Getting the below error in Android.

    The Android Gradle plugin supports only Kotlin Gradle plugin version 1.2.51 and higher. Project 'flutter_country_picker' is using version 1.2.30.

    opened by anoop4real 2
  • Encounter no able to compile

    Encounter no able to compile

    Hi, I have encounter the issues when I compile my program with your plugin e: C:\Users\user\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_country_picker-0.1.0\android\src\main\kotlin\rocks\biessek\fluttercountrypicker\FlutterCountryPickerPlugin.kt: (26, 46): Type inference failed. Expected type mismatch: inferred type is ArrayList? but ArrayList was expected

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':flutter_country_picker:compileDebugKotlin'.

    Compilation error. See log for more details

    The gradle version I used is 'com.android.tools.build:gradle:3.1.2' without set other kotlin plug.

    Below logic is how I used your country picker plugin: Widget countryField(){

    if (_isChangeInfo == true ) {
    
    Widget countryMenuList = new Container(
     child: new Row(
        children: <Widget>[
          CountryPicker(
            onChanged: (Country country) {
              setState(() {
                _selected = country;
                _countryName=country.name;
              });
            },
            selectedCountry: _selected,
          ),
          Text(_countryName, style: new TextStyle(color: Colors.black, fontSize: 16.00),),
        ],
      )
    );
    
    opened by xuncoder 2
  • Added currency properties

    Added currency properties

    Hi. I was unable to test the changes because i was having an error.

    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:signingConfigWriterDebug'.
    > java.nio.file.AccessDeniedException: C:\Users\Alfred\AndroidStudioProjects\flutter_country_picker\example\build\app\intermediates\signing_config\debug\out\signing-config.json
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 22s
    Finished with error: Gradle task assembleDebug failed with exit code 1
    
    

    kindly check before merging. And do you know how to fix my error???

    opened by Alfie-AD 1
  • Bad state: No element error

    Bad state: No element error

    Hello, I have an error when trying to integrate your module.

    In my pubspec.yaml: dependencies: flutter_country_picker: ^0.1.4

    My code: Country _country; ... CountryPicker( dense: false, showFlag: true, showDialingCode: false, showName: true, onChanged: (Country country) { setState(() { _country = country; }); }, selectedCountry: _country, ),

    I got the following error: 09:43:07.055 2 info flutter.tools I/flutter (26704): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ 09:43:07.055 3 info flutter.tools I/flutter (26704): The following StateError was thrown building CountryPicker(dirty, dependencies: 09:43:07.055 4 info flutter.tools I/flutter (26704): [_LocalizationsScope-[GlobalKey#5ca4e]]): 09:43:07.055 5 info flutter.tools I/flutter (26704): Bad state: No element 09:43:07.055 6 info flutter.tools I/flutter (26704): 09:43:07.055 7 info flutter.tools I/flutter (26704): When the exception was thrown, this was the stack: 09:43:07.055 8 info flutter.tools I/flutter (26704): #0 _ListBase&Object&ListMixin.singleWhere (dart:collection/list.dart:178:5) 09:43:07.055 9 info flutter.tools I/flutter (26704): #1 Country.findByIsoCode (package:flutter_country_picker/country.dart:1793:16) 09:43:07.055 10 info flutter.tools I/flutter (26704): #2 CountryPicker.build (package:flutter_country_picker/flutter_country_picker.dart:60:19) 09:43:07.055 11 info flutter.tools I/flutter (26704): #3 StatelessElement.build (package:flutter/src/widgets/framework.dart:3885:28)

    I am on the latest flutter version, channel stable.

    Thank you

    opened by 0xecute 1
  • The overflowing RenderFlex has an orientation of Axis.horizontal

    The overflowing RenderFlex has an orientation of Axis.horizontal

    when we are try to put in side the TextFormField phone flutter

              TextFormField(
                obscureText: true,
                controller: _passwordCtrl,
                onSaved: (String value) {
                  _phone= value;
                },
            
                validator: (value) =>
                    value.isEmpty ? 'phone can\'t be empty' : null,
                decoration: _themePage.textBoxDecorationForPhoneNumber(
                  
                    IconButton(
                      iconSize: 32.0,
                        icon: CountryPicker(
                      showDialingCode: true,
                      showName: false,
                      showFlag: true,
                      onChanged: (Country country) {
                        setState(() {
                          _selected = country;
                        });
                      },
                      selectedCountry: _selected,
                    ),
                        onPressed: () {
                        }),
                    "Phone"),
              ),
    
    opened by sivatharan 1
  • Collaboration

    Collaboration

    Hi. i forked your package and edited a little bit for my use. i made it so i see the country name and flag when one is selected. here if you want to check it out add maybe update pub.

    updated example:

    CountryPicker(
             dense: false,
             showFlag: true,  //displays flag, true by default
             showDialingCode: false, //displays dialing code, false by default
             showName: true, //displays country name, true by default
             onChanged: (Country country) {
               setState(() {
                 _selected = country;
               });
             },
             selectedCountry: _selected,
           ),
    
    
    enhancement 
    opened by Alfie-AD 1
  • Type inference failed. Expected type mismatch: inferred type is Array…

    Type inference failed. Expected type mismatch: inferred type is Array…

    …List? but ArrayList was expected

    Fixed issue that appeared with the new update on Kotlin/Flutter on Linux.

    /development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_country_picker-0.1.0/android/src/main/kotlin/rocks/biessek/fluttercountrypicker/FlutterCountryPickerPlugin.kt: (26, 46): Type inference failed. Expected type mismatch: inferred type is ArrayList? but ArrayList was expected

    FAILURE: Build failed with an exception.

    • What went wrong: Execution failed for task ':flutter_country_picker:compileDebugKotlin'.

    Compilation error. See log for more details

    opened by GuruJohn 0
  • deprecated version of the Android embedding.

    deprecated version of the Android embedding.

    The plugin flutter_country_picker uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

    opened by Calvin2274 0
  • fatal error: module 'flutter_country_picker' not found

    fatal error: module 'flutter_country_picker' not found

    Running pod install...                                              5.4s
    Running Xcode build...                                                  
     └─Compiling, linking and signing...                        10.4s
    Xcode build done.                                           74.5s
    Failed to build iOS app
    Error output from Xcode build:
    ↳
        ** BUILD FAILED **
    
    
    Xcode's output:
    ↳
        /ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module 'flutter_country_picker' not found
        @import flutter_country_picker;
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
        1 error generated.
        note: Using new build system
        note: Building targets in parallel
        note: Planning build
        note: Constructing build description
    

    Flutter doctor:

    [✓] Flutter (Channel beta, 1.24.0-10.2.pre, on macOS 11.0.1 20B29 darwin-x64, locale en-GB)
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    [✓] Xcode - develop for iOS and macOS (Xcode 12.2)
    [✓] Android Studio (version 4.1)
    [✓] VS Code (version 1.52.0)
    [✓] Connected device (1 available)
    
    opened by sulaysumaria 0
  • Does not show flags images

    Does not show flags images

    Hi, in my Flutter app flags are not showing. May be some additional steps have to be done, but I didn't find that in the install description. Other than than, the picker works fine. showFlag is set to true. showFlag: true, //displays flag, true by default I'll appreciate help with this issue, thanks in advance.

    opened by ajbarsu 3
  • Assign value to Model class

    Assign value to Model class

    Hello,

    Please can you help me out to assigned the _selected value of your CountryPicker , to my Model class for managing all my for data.

    I wanted to assign the _selected value to this.model.country in my Model(), so it is easy to show the selected country result in a new screen. I am new to flutter, please can you help me out. Thank in advance.

    opened by token-lyd 0
  • No option to customise dropdown text style

    No option to customise dropdown text style

    Changes requested:

    • Dropdown text style taken from subtitle text style automatically
    • Requesting an option to customise the text style
    • Also ability to remove country code from dropdown
    opened by ParthKharwar 0
Owner
Alessandro Biessek
Android & Backend Developer
Alessandro Biessek
starlight_country_picker is a country picker.

Starlight Country Picker starlight_country_picker is a country picker. Features ☑️ Add New Country ☑️ Search Your Country ⭐ Our package was not used s

Ye Myo Aung 1 Nov 29, 2021
Build a grouped list, which support expand/collapse section and sticky headers, support use it with sliver widget.

sticky_and_expandable_list Flutter implementation of sticky headers and expandable list.Support use it in a CustomScrollView. README i18n:中文说明 Feature

tp7309 114 Nov 16, 2022
An assets picker in WeChat style, support multi assets picking.

An assets picker in WeChat style, support multi assets picking.

FlutterCandies 1.1k Jan 8, 2023
Donation/Support buttons to allow you to add your favorite support buttons like: Paypal, Ko-fi or Patreon and more.

flutter_donation_buttons Donation/Support buttons to allow you to add your favorite support buttons like: Paypal, Ko-fi or Patreon and more. Getting S

null 6 Dec 10, 2022
A flutter carousel widget, support infinite scroll, and custom child widget.

carousel_slider A carousel slider widget. Features Infinite scroll Custom child widgets Auto play Supported platforms Flutter Android Flutter iOS Flut

Bart T 1 Nov 25, 2021
A flutter package to select a country from a list of countries.

Country picker A flutter package to select a country from a list of countries. Getting Started Add the package to your pubspec.yaml: country_picker: ^

Daniel Ioannou 60 Dec 30, 2022
A time picker widget for flutter

time_picker A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Ramon Alex 4 Dec 3, 2022
Flutter Number Picker is a custom widget designed for choosing an integer or decimal number by using add and minus buttons

Flutter Number Picker is a custom widget designed for choosing an integer or decimal number by using add and minus buttons. Getting Started Head to /p

Vũ Phương 2 Jul 4, 2022
Flutter Color Picker Wheel - an easy to use widget which can be heavily customized

Flutter Color Picker Wheel Flutter Color Picker Wheel is an easy to use widget which can be heavily customized. You can use the WheelColorPicker direc

Kexin Lu 35 Oct 4, 2022
A Flutter Text widget support word break for CJK

word_break_text Text widget with word break support for CJK sentence. Installation Add flutter_map to your pubspec: dependencies: word_break_text:

ChangJoo Park(박창주) 5 Nov 11, 2022
Plugin to the JSON Dynamic Widget to provide named support for Ionicons

json_dynamic_widget_plugin_ionicons Table of Contents Live Example Introduction Using the Plugin Live Example Web Introduction Plugin to the JSON Dyna

null 0 May 14, 2022
PowerFileView - A powerful file view widget, support a variety of file types, such as Doc Eexcl PPT TXT PDF and so on, Android is implemented by Tencent X5, iOS is implemented by WKWebView.

PowerFileView - A powerful file view widget, support a variety of file types, such as Doc Eexcl PPT TXT PDF and so on, Android is implemented by Tencent X5, iOS is implemented by WKWebView.

Yao 8 Oct 22, 2022
A flutter horizontal date picker that always shift the selected date to center.

horizontal_center_date_picker A flutter widget provides a horizontal date picker and always aligns selected date in center of the widget. Usage This s

May Lau 5 Jul 2, 2022
A flutter package for displaying common picker dialogs.

Flutter Material Pickers A flutter package containing commonly used material design picker dialogs. Some are new, some wrap existing or built in picke

CodeGrue 89 Jan 2, 2023
Flutter picker plugin

flutter_picker Flutter plugin picker. Include NumberPicker, DateTimePicker, ArrayPicker, and default linkage Picker. Provide flexible parameters to me

null 614 Dec 23, 2022
A beautiful circle color picker for flutter.

A beautiful circle color picker for flutter.

Takeshi Tsukamoto 46 Dec 29, 2022
A camera picker in WeChat style.

A camera picker which is an extension for wechat_assets_picker. Based on camera for camera functions and photo_manager for asset implementation.

FlutterCandies 265 Dec 28, 2022
Ejimo - Comprehensive emoji and symbol picker.

Ejimo Find and copy unicode characters, emoticons, glyphs and symbols with Ejimo. Ejimo is a comprehensive emoji and symbol piker that puts every char

null 20 Dec 19, 2022
Flutter progress dialog. Support both Android and iOS platform.

Flutter Progress Dialog [pub packages] | Flutter progress dialog. Support both Android and iOS platform

Dylan Wu 22 Oct 9, 2022