flutter_country_code

Searchable country picker service with sim card detect , copied from https://github.com/dev-naiksan/country-calling-code-picker

1: Import the plugin using

 import 'package:flutter_country_code/picker.dart';

2: trigger the service by default country.

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

3: Use widget CountryPickerWidget to get the list of the countries.

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

4: support locale by trigger :

 locale: Localizations.localeOf(context).languageCode,} //in CountryPickerWidget
 //or
 _selectedCountry.nameTranslations['en'] // it can be jp , ar ..etc

5: 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);

6: 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');

7: phone number validation and formating with standerd forms using native sdks for android and iOS :

 PhoneNumberTools.format(params...);
 PhoneNumberTools.validate(params...);