Add support for manually showing dialog
Closed this issue · 3 comments
Gintasz commented
Currently there is no support to manually open a country selection dialog. It would be a great addition if added.
imtoori commented
Now you can use a GlobalKey to show the dialog
ch-muhammad-adil commented
Hey can you explain more about using globalkey i am currently trying it like this
navigatorKey.currentState.overlay.context
can you provide some code?
ch-muhammad-adil commented
So I am able to achieve this, i have created a key of CountryCodePickerState
final _countryPicker = GlobalKey<CountryCodePickerState>();
CountryCodePicker(
key:_countryPicker, ///assigned the key here
onChanged: (value) {
_countryCode = value.dialCode;
},
initialSelection: _countryCode,
favorite: ['+41', 'PK', '+49'],
showCountryOnly: true,
showOnlyCountryWhenClosed: false,
alignLeft: false,
),
Now I have created a button and in on press of that button calling this code works
_countryPicker.currentState.showCountryCodePickerDialog();