Last updated:
0 purchases
flutter country code
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';
copied to clipboard
2: trigger the service by default country.
void initCountry() async {
final country = await getDefaultCountry(context);
setState(() {
_selectedCountry = country;
});
}
copied to clipboard
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;
});
}
}
copied to clipboard
4: support locale by trigger :
locale: Localizations.localeOf(context).languageCode,} //in CountryPickerWidget
//or
_selectedCountry.nameTranslations['en'] // it can be jp , ar ..etc
copied to clipboard
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);
copied to clipboard
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');
copied to clipboard
7: phone number validation and formating with standerd forms using native sdks for android and iOS :
PhoneNumberTools.format(params...);
PhoneNumberTools.validate(params...);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.