countrycodes_field 0.1.0 copy "countrycodes_field: ^0.1.0" to clipboard
countrycodes_field: ^0.1.0 copied to clipboard

Choose Country Codes Efficiently

Contry Codes 🌍 #

A list of all the country codes, dial codes, their corresponding country names, and flag.

Features #

You can use the following features:

  1. Show the user a customizable Text Field to select Country Code. 🚀
  2. Find the dial code of a specific country. 🔍

Extras

  1. Have access to all the country codes.
  2. Get the country code by country name.
  3. Get the country name by country code.
  4. Get the country by dial code.

⚙️ Getting started #

Install the package by adding the following line into your pubspec.yaml file:

dependencies:
  countrycodes_field: <VERSION>

Now import the package into your project:

import 'package:countrycodes_field/countrycodes.dart';

📚 Usage #

1. Country Field 🚀 #

To show the user a customizable Text Field to select Country Code, use the following code:

CountryField(
    onSelect: (Country c) {
        print('Selected country: $c');
    },
)
         

2. Find Country 🔍 #

Second, to find the dial code of a specific country, use the following code:

var country = Countries.findByName("United Kingdom");

print(country.flag); // 🇬🇧

Similarly, you can get the country code, country name, and country flag by country name, country code, and dial code.

var c1 = Countries.findByName("United Kingdom");
var c2 = Countries.findByCode("GB");
var c3 = Countries.findByDialCode("44");

print(c1 == c2); // true
print(c1 == c3); // true

If the country is not found, an exception will be thrown.

Model 🧑🏻‍💻 #

Country object is as shown below:

class Country {
  final String name;
  final String code;
  final String dialCode;
  final String flag;

  const Country({
    required this.name,
    required this.code,
    required this.dialCode,
    required this.flag,
  });
}

Contribute 💻 #

If you'd like to have a feature added, please open an issue or create a pull request.

License 🔑 #

License details can be found in the LICENSE file.

2
likes
100
pub points
49%
popularity

Publisher

unverified uploader

Choose Country Codes Efficiently

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on countrycodes_field