showCountryCodePickerBottomSheet function
Future<Country?>
showCountryCodePickerBottomSheet({
- required BuildContext context,
- List<
Country> countries = const [], - Country? initiallySelected,
- List<
String> favorite = const [], - CountryPickerStyle style = const CountryPickerStyle(),
Present the modal bottom sheet and return the selected country.
If countries is empty, uses a small built-in demo list.
initiallySelectedpre-selects a country in the list.favoritepins countries (ISO2 or dial codes) as quick chips.
Implementation
Future<Country?> showCountryCodePickerBottomSheet({
required BuildContext context,
List<Country> countries = const [],
Country? initiallySelected,
List<String> favorite = const [],
CountryPickerStyle style = const CountryPickerStyle(),
}) {
final all = (countries.isEmpty) ? _defaultCountries : normalizeCountries(countries);
return showModalBottomSheet<Country>(
context: context,
isScrollControlled: true,
useSafeArea: true,
backgroundColor: Theme.of(context).colorScheme.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(style.cornerRadius)),
),
builder: (ctx) {
return _CountryPickerSheet(
all: all,
selected: initiallySelected ?? (all.isNotEmpty ? all.first : null),
favorite: favorite,
style: style,
);
},
);
}