country_pickers 1.0.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 97

country_pickers #

Countries, codes, flags and several way of picking them at your service...one widget away...

CountryPickerDropdown example #
 CountryPickerDropdown(
            initialValue: 'tr',
            itemBuilder: _buildDropdownItem,
            onValuePicked: (Country country) {
              print("${country.name}");
            },
          ),
 Widget _buildDropdownItem(Country country) => Container(
        child: Row(
          children: <Widget>[
            CountryPickerUtils.getDefaultFlagImage(country),
            SizedBox(
              width: 8.0,
            ),
            Text("+${country.phoneCode}(${country.isoCode})"),
          ],
        ),
      );
CountryPickerDialog example #
void _openCountryPickerDialog() => showDialog(
        context: context,
        builder: (context) => Theme(
            data: Theme.of(context).copyWith(primaryColor: Colors.pink),
            child: CountryPickerDialog(
                titlePadding: EdgeInsets.all(8.0),
                searchCursorColor: Colors.pinkAccent,
                searchInputDecoration: InputDecoration(hintText: 'Search...'),
                isSearchable: true,
                title: Text('Select your phone code'),
                onValuePicked: (Country country) =>
                    setState(() => _selectedDialogCountry = country),
                itemBuilder: _buildDialogItem)),
      );
CountryPickerCupertino example #
 void _openCupertinoCountryPicker() => showCupertinoModalPopup<void>(
      context: context,
      builder: (BuildContext context) {
        return CountryPickerCupertino(
          pickerSheetHeight: 300.0,
          onValuePicked: (Country country) =>
              setState(() => _selectedCupertinoCountry = country),
        );
      });

Credits #

Thanks goes to country-flags repo for the flag image assets.

[1.0.4] - 04/14/2019

  • Fix issue #7 - Add iso3Code. Thanks @endigo

[1.0.3] - 04/12/2019

  • Fix issue #9 - Ability to filter countries. Thanks @ened

[1.0.2] - 03/27/2019

  • Fix issue #6 Thanks @rafe211
  • Fix documentation error. PR #3 Thanks @GeertJohan

[1.0.1] - 10/09/2018

  • CountryPickerDropdown's onValuePicked doesn't feel useless anymore. [Thanks Solomon Nsumei @solnsumei]

[1.0.0] - 9/22/2018

  • Initial release 🎉
  • CountryPickerDropdown
  • CountryPickerDialog
  • CountryPickerCupertino
  • Country flag image assets and list of maps which has country name, iso code, phone code.

example/README.md

country_pickers example #

Example project that shows usage of country_pickers library.

CountryPickerDropdown example #
 CountryPickerDropdown(
            initialValue: 'tr',
            itemBuilder: _buildDropdownItem,
            onValuePicked: (Country country) {
              print("${country.name}");
            },
          ),
 Widget _buildDropdownItem(Country country) => Container(
        child: Row(
          children: <Widget>[
            CountryPickerUtils.getDefaultFlagImage(country),
            SizedBox(
              width: 8.0,
            ),
            Text("+${country.phoneCode}(${country.isoCode})"),
          ],
        ),
      );
CountryPickerDialog example #
void _openCountryPickerDialog() => showDialog(
        context: context,
        builder: (context) => Theme(
            data: Theme.of(context).copyWith(primaryColor: Colors.pink),
            child: CountryPickerDialog(
                titlePadding: EdgeInsets.all(8.0),
                searchCursorColor: Colors.pinkAccent,
                searchInputDecoration: InputDecoration(hintText: 'Search...'),
                isSearchable: true,
                title: Text('Select your phone code'),
                onValuePicked: (Country country) =>
                    setState(() => _selectedDialogCountry = country),
                itemBuilder: _buildDialogItem)),
      );
CountryPickerCupertino example #
 void _openCupertinoCountryPicker() => showCupertinoModalPopup<void>(
      context: context,
      builder: (BuildContext context) {
        return CountryPickerCupertino(
          pickerSheetHeight: 300.0,
          onValuePicked: (Country country) =>
              setState(() => _selectedCupertinoCountry = country),
        );
      });

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  country_pickers: ^1.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:country_pickers/country_pickers.dart';
  
Version Uploaded Documentation Archive
1.0.4 Apr 14, 2019 Go to the documentation of country_pickers 1.0.4 Download country_pickers 1.0.4 archive
1.0.3 Apr 12, 2019 Go to the documentation of country_pickers 1.0.3 Download country_pickers 1.0.3 archive
1.0.2 Mar 27, 2019 Go to the documentation of country_pickers 1.0.2 Download country_pickers 1.0.2 archive
1.0.1 Oct 9, 2018 Go to the documentation of country_pickers 1.0.1 Download country_pickers 1.0.1 archive
1.0.0 Sep 22, 2018 Go to the documentation of country_pickers 1.0.0 Download country_pickers 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

We analyzed this package on Apr 23, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/country_picker_cupertino.dart. (-0.50 points)

Analysis of lib/country_picker_cupertino.dart reported 1 hint:

line 88 col 17: The value of the field '_allCountries' isn't used.

Format lib/country_picker_dialog.dart.

Run flutter format to format lib/country_picker_dialog.dart.

Format lib/country_picker_dropdown.dart.

Run flutter format to format lib/country_picker_dropdown.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test