showCountryPickerDialog method
Future<Country?>
showCountryPickerDialog(
- BuildContext context, {
- Widget? title,
- double cornerRadius = 20,
- bool focusSearchBox = false,
- List<
String> filteredCountries = const [], - TextStyle itemTextStyle = const TextStyle(fontSize: 16),
- TextStyle searchInputStyle = const TextStyle(fontSize: 16),
- InputDecoration? searchInputDecoration,
- double flagIconWidth = 32,
- double flagIconHeight = 22,
- bool showSeparator = false,
- String searchHintText = "Search country name, code",
Implementation
Future<Country?> showCountryPickerDialog(BuildContext context,
{Widget? title,
double cornerRadius = 20,
bool focusSearchBox = false,
List<String> filteredCountries = const [],
TextStyle itemTextStyle = const TextStyle(fontSize: 16),
TextStyle searchInputStyle = const TextStyle(fontSize: 16),
InputDecoration? searchInputDecoration,
double flagIconWidth = 32,
double flagIconHeight = 22,
bool showSeparator = false,
String searchHintText = "Search country name, code"}) async {
return await showDialog<Country?>(
context: context,
barrierDismissible: true,
builder: (_) => Dialog(
insetPadding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(cornerRadius),
)),
child: Column(
children: <Widget>[
const SizedBox(height: 12),
Stack(
children: <Widget>[
Positioned(
right: 8,
top: 0,
bottom: 0,
child: TextButton(
style: const ButtonStyle(
padding: WidgetStatePropertyAll(
EdgeInsets.symmetric(vertical: 4))),
onPressed: () => Navigator.pop(context),
child: const Text("Cancel")),
),
Center(
child: title ??
const Text(
'Choose country',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w500,
),
),
),
],
),
const SizedBox(height: 12),
Expanded(
child: AdvanceCountryPickerWidget(
onSelected: (country) =>
Navigator.of(context).pop(country),
filteredCountries: filteredCountries,
itemTextStyle: itemTextStyle,
searchHintText: searchHintText,
searchInputDecoration: searchInputDecoration,
searchInputStyle: searchInputStyle,
showSeparator: showSeparator,
flagIconWidth: flagIconWidth,
flagIconHeight: flagIconHeight,
focusSearchBox: focusSearchBox,
),
),
],
),
));
}