CSCPicker(
showCities: false,
onCountryChanged: (country) {
List<String> parts = country.split(" ");
String code = parts.first;
String name = parts.last;
stateAction.updateCountry(name, code);
},
onStateChanged: (stateName) {
if (stateName != null) {
stateAction.updateCity(stateName);
}
},
onCityChanged: (value) {},
),
The above code is perfectly working for new entry but when I am going to edit the existing record, the state is disabled. Hence I have to change the country first. So is there any way to trigger onCountryChanged
of CSCPicker
widget from provider class at initial state ?
2
Answers
Try setting
defaultCountry
property ofCSCPicker
with the selected country – this way you should have it preselected on change.This should do the trick