Open ghost opened 2 years ago
Try this
///triggers once country selected in dropdown
onCountryChanged: (value) {
setState(() {
///store value in country variable
countryValue = value;
});
},
///triggers once state selected in dropdown
onStateChanged: (value) {
setState(() {
///store value in state variable
stateValue = value ?? "";
});
},
///triggers once city selected in dropdown
onCityChanged: (value) {
setState(() {
///store value in city variable
cityValue = value ?? "";
});
still makeing problem if you can edit my code will be fine
I had a similar error that occurred because when you change the value of country and state, the callbacks of its children state and city or just city in the case of the state, are called passing the NULL value as a parameter, this occurs because the state is /or city is reset to not have invalid combinations.
To prevent the error you just need to create the 3 onchange callbacks, for country, city and state keeping in mind that they will be called passing the NULL parameter.
sorry, translator inglish. I am Brazilian.
E/flutter (20371): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value E/flutter (20371): #0 CSCPickerState._onSelectedCountry. (package:csc_picker/csc_picker.dart:741:35)
E/flutter (20371): #1 State.setState (package:flutter/src/widgets/framework.dart:1109:30)
E/flutter (20371): #2 CSCPickerState._onSelectedCountry (package:csc_picker/csc_picker.dart:723:5)
E/flutter (20371): #3 CSCPickerState._setDefaultCountry (package:csc_picker/csc_picker.dart:618:7)
E/flutter (20371): #4 CSCPickerState.getCountries (package:csc_picker/csc_picker.dart:647:5)
E/flutter (20371):
E/flutter (20371):