country_calling_code_picker 2.0.1 copy "country_calling_code_picker: ^2.0.1" to clipboard
country_calling_code_picker: ^2.0.1 copied to clipboard

Flexible Country picker for getting Country code and Calling code.

Country Calling Code Picker #

Searchable country picker widget ready to use in a dialog, bottom sheet and even in full screen!

1: Import the plugin using

 import 'package:country_calling_code_picker/picker.dart';
copied to clipboard

2: Initialize your UI using default country.

  void initCountry() async {
    final country = await getDefaultCountry(context);
    setState(() {
      _selectedCountry = country;
    });
  }
copied to clipboard

3: Use utility function showCountryPickerSheet to show a bottom sheet picker.

void _showCountryPicker() async{
    final country = await showCountryPickerSheet(context,);
    if (country != null) {
      setState(() {
        _selectedCountry = country;
      });
    }
}
copied to clipboard

4: Use utility function showCountryPickerDialog to show a dialog.

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

5: CountryPickerWidget can be used for showing in a full screen.

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),
        ),
      ),
    );
  }
}
copied to clipboard
  1. If you just need the list of countries for making your own custom country picker, you can all getCountries() which returns list of countries.
List<Country> list = await getCountries(context);
copied to clipboard
  1. If you want to get flag from the country code, you can use below method to get country using the country code. Eg. for getting India's flag,
Country country = await getCountryByCountryCode(context, 'IN');
copied to clipboard
45
likes
150
points
949
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.06 - 2025.04.20

Flexible Country picker for getting Country code and Calling code.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_sim_country_code

More

Packages that depend on country_calling_code_picker