fayaz07 / flutter_firebase

Implementing features of firebase with flutter
92 stars 67 forks source link

How to set _selectedCountryIndex can be values according to the phone's country automatically at first? #8

Closed wann2 closed 4 years ago

wann2 commented 4 years ago

Great codes!

Is there any way that _selectedCountryIndex can be values according to the phone's country automatically at first?

fayaz07 commented 4 years ago

Hi, thanks. Yeah you can do that by changing the code below and at this widget.

 void selectThisCountry(Country country) {
    print(country);
    _searchCountryController.clear();
    Navigator.of(context).pop();
    Future.delayed(Duration(milliseconds: 10)).whenComplete(() {
      _countriesStreamController.close();
      _countriesSink.close();

      setState(() {
        _selectedCountryIndex = countries.indexOf(country);
// change here
      });
    });
  }