country_code_manager 1.0.0 copy "country_code_manager: ^1.0.0" to clipboard
country_code_manager: ^1.0.0 copied to clipboard

This package is used to get country code and country name from country code.

country_code #

Pub Version

A Flutter package to simplify the use of country codes, names, and flags in your applications.

Features #

  • Easy Country Selection: Provides a convenient widget for selecting countries from a list.
  • Customizable: Adjust flag size, display format, and other properties.
  • Localized Country Names: Supports multiple languages for displaying country names.
  • Asset Integration: Seamlessly integrates with your app's assets for flag images.

Installation #

Add the country_code package to your pubspec.yaml file:

dependencies:
  country_code: ^latest_version

Usage

Initialization

Initialize the CountryCodeManager in your app's initialization process:

  await CountryCodeManager.instance.init();

Displaying Country Flags

Use the ShowFlag widget to display a flag for a specific country code:

ShowFlag(countryCode: 'US') // Displays the flag for the United States

Country Selection Widget

Create a dropdown or other interactive widget to allow users to select a country:

DropdownButton<String>(
  items: CountryCodeManager.instance.countries.map((Country country) {
    return DropdownMenuItem<String>(
      value: country.code,
      child: Row(
        children: [
          ShowFlag(countryCode: country.code, width: 24),
          SizedBox(width: 8),
          Text(country.name),
        ],
      ),
    );
  }).toList(),
  onChanged: (value) {
    // Handle country selection
  },
)

Localization (Optional)

To use localized country names, provide the language parameter during initialization:

await CountryCodeManager.instance.init(SupportedLanguage.en); // English

Supported Languages:

English (en) Customization

Flag Size: Adjust width and height properties of the ShowFlag widget. Fit: Use the fit property to control how the flag image fits within the widget. Add More Languages: Expand the SupportedLanguage enum and add corresponding JSON files in the locale folder.

5
likes
0
points
32
downloads

Publisher

verified publisherefestech.com.tr

Weekly Downloads

This package is used to get country code and country name from country code.

License

unknown (license)

Dependencies

flutter

More

Packages that depend on country_code_manager