From 4e0a31439bed175c8d1cec8c775eed2156302cba Mon Sep 17 00:00:00 2001 From: julis Date: Sat, 4 Sep 2021 09:58:30 +0300 Subject: [PATCH 1/3] give the countryPickerDialog a key value and give showDialog the userRootNavigator: false --- lib/country_code_picker.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index c979e12b..7f4209ca 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -84,6 +84,9 @@ class CountryCodePicker extends StatefulWidget { /// with customized codes. final List> countryList; + static const Key countryCodePickerDialogKey = Key + ("countryCodePickerDialogKey"); + CountryCodePicker({ this.onChanged, this.onInit, @@ -284,11 +287,13 @@ class CountryCodePickerState extends State { void showCountryCodePickerDialog() { 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( @@ -327,9 +332,11 @@ class CountryCodePickerState extends State { showMaterialModalBottomSheet( barrierColor: widget.barrierColor ?? Colors.grey.withOpacity(0.5), backgroundColor: widget.backgroundColor ?? Colors.transparent, + useRootNavigator: false, context: context, builder: (context) => Center( child: SelectionDialog( + key: CountryCodePicker.countryCodePickerDialogKey, elements, favoriteElements, showCountryOnly: widget.showCountryOnly, From a19bef8b44e967df57c750b22c54350259685d6e Mon Sep 17 00:00:00 2001 From: julis Date: Sat, 4 Sep 2021 10:22:38 +0300 Subject: [PATCH 2/3] give the countryPickerDialog a key value and give showDialog the userRootNavigator: false --- lib/country_code_picker.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 7f4209ca..34e80ceb 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -336,7 +336,6 @@ class CountryCodePickerState extends State { context: context, builder: (context) => Center( child: SelectionDialog( - key: CountryCodePicker.countryCodePickerDialogKey, elements, favoriteElements, showCountryOnly: widget.showCountryOnly, From 5ecf82d606a5174133aee6e025827b135c6ecde1 Mon Sep 17 00:00:00 2001 From: heriniaina-rak <71939019+heriniaina-rak@users.noreply.github.com> Date: Thu, 21 Oct 2021 12:28:48 +0300 Subject: [PATCH 3/3] Update country_code_picker.dart --- lib/country_code_picker.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/country_code_picker.dart b/lib/country_code_picker.dart index 34e80ceb..7c4460ee 100644 --- a/lib/country_code_picker.dart +++ b/lib/country_code_picker.dart @@ -285,6 +285,14 @@ class CountryCodePickerState extends State { } 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,