Country picker
Here’s flutter package hat allows You to select a country from a list of countries. It can be used in various type of Apps, as it builds you a list of all countries, and make it selectable.
ScreenShot
Getting Started
Add the package to your pubspec.yaml:
ADVERTISEMENT
country_picker: ^1.0.4
In your dart file, import the library:
import 'package:country_picker/country_picker.dart';
Show country picker using showCountryPicker
:
showCountryPicker( context: context, showPhoneCode: true, // optional. Shows phone code before the country name. onSelect: (Country country) { print('Select country: ${country.displayName}'); }, );
Parameters:
onSelect
: Called when a country is select. The country picker passes the new value to the callback (required)showPhoneCode
: Can be used to to show phone code before the country name.exclude
: Can be used to exclude(remove) one ore more country from the countries list (optional).
showCountryPicker( context: context, exclude: <String>['KN', 'MF'], //It takes a list of country code(iso2). onSelect: (Country country) => print('Select country: ${country.displayName}'), );
Dart