imtoori/CountryCodePicker

Add support for manually showing dialog

Closed this issue · 3 comments

Currently there is no support to manually open a country selection dialog. It would be a great addition if added.

Now you can use a GlobalKey to show the dialog

Hey can you explain more about using globalkey i am currently trying it like this

navigatorKey.currentState.overlay.context

can you provide some code?

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();