fayaz07/flutter_firebase

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

wann2 opened this issue · 1 comments

wann2 commented

Great codes!

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

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