Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

give the countryPickerDialog a key value and give showDialog the user… #173

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/country_code_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class CountryCodePicker extends StatefulWidget {
/// with customized codes.
final List<Map<String, String>> countryList;

static const Key countryCodePickerDialogKey = Key
("countryCodePickerDialogKey");

CountryCodePicker({
this.onChanged,
this.onInit,
Expand Down Expand Up @@ -282,13 +285,23 @@ class CountryCodePickerState extends State<CountryCodePicker> {
}

void showCountryCodePickerDialog() {
favoriteElements = elements
.where((e) =>
widget.favorite.firstWhereOrNull((f) =>
e.code!.toUpperCase() == f.toUpperCase() ||
e.dialCode == f ||
e.name!.toUpperCase() == f.toUpperCase()) !=
null)
.toList();
if (!UniversalPlatform.isAndroid && !UniversalPlatform.isIOS) {
showDialog(
useRootNavigator: false,
barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5),
// backgroundColor: widget.backgroundColor ?? Colors.transparent,
context: context,
builder: (context) => Center(
child: Container(
key: CountryCodePicker.countryCodePickerDialogKey,
constraints: BoxConstraints(maxHeight: 500, maxWidth: 400),
child: Dialog(
child: SelectionDialog(
Expand Down Expand Up @@ -327,6 +340,7 @@ class CountryCodePickerState extends State<CountryCodePicker> {
showMaterialModalBottomSheet(
barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5),
backgroundColor: widget.backgroundColor ?? Colors.transparent,
useRootNavigator: false,
context: context,
builder: (context) => Center(
child: SelectionDialog(
Expand Down