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

Add support for manually showing dialog #60

Closed
Gintasz opened this issue Mar 30, 2020 · 3 comments
Closed

Add support for manually showing dialog #60

Gintasz opened this issue Mar 30, 2020 · 3 comments

Comments

@Gintasz
Copy link

Gintasz commented Mar 30, 2020

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

@imtoori
Copy link
Owner

imtoori commented Apr 4, 2020

Now you can use a GlobalKey to show the dialog

@imtoori imtoori closed this as completed Apr 4, 2020
@ch-muhammad-adil
Copy link

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants