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

A customizable widget to select international dialing codes.

global_dial_code_picker #

This package is inspired by the country-calling-code-picker written in Dart. We extend our sincere thanks to the original author for their excellent work.

A searchable country picker widget that supports multiple UI presentations: dialog, bottom sheet, and full screen.


Features #

  • Searchable list of countries with dialing codes
  • Multiple picker styles: dialog, bottom sheet, fullscreen widget
  • Easy integration and usage
  • Retrieve country flags by country code
  • Utility functions for default and custom country selection

Installation #

Add this to your pubspec.yaml:

dependencies:
   global_dial_code_picker: ^1.0.0

Then run:

flutter pub get

Usage #

1: Import the plugin using

import 'package:global_dial_code_picker/global_dial_code_picker.dart';

2: Initialize your UI using default country.

  void initCountry() async {
    final country = await getDefaultCountry();
    setState(() {
      _selectedCountry = country;
    });
  }

3: Show country picker as a bottom sheet

void _showCountryPicker() async{
    final country = await showCountryPickerSheet();
    if (country != null) {
      setState(() {
        _selectedCountry = country;
      });
    }
}

4: Show country picker as a dialog

void _showCountryPicker() async{
    final country = await showCountryPickerDialog(context);
    if (country != null) {
      setState(() {
        _selectedCountry = country;
      });
    }
}

5: Use CountryPickerWidget for full screen picker

class PickerPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Select Country'),
      ),
      body: Container(
        child: CountryPickerWidget(
          onSelected: (country) => Navigator.pop(context, country),
        ),
      ),
    );
  }
}

6: Get list of all countries (for custom country picker)

List<Country> list = await getCountries();

7: Get a country by country code (to retrieve flag or other info) Example: get Pakistan's country data

Country country = await getCountryByCountryCode('PK');

License #

This project is licensed under the MIT License.

You are free to use, modify, and distribute this package for personal and commercial purposes, provided that the original copyright notice and permission notice are included in all copies or substantial portions of the software.

1
likes
0
points
35
downloads

Publisher

verified publishermwaqas.mobvers.com

Weekly Downloads

A customizable widget to select international dialing codes.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

device_region, flutter, flutter_web_plugins

More

Packages that depend on global_dial_code_picker