country picker
a flutter package to select a country from a list of countries.
getting started
add the package to your pubspec.yaml:
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}'),
);
Comments are closed.