Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSCPickerState._onSelectedCountry #52

Open
ghost opened this issue May 12, 2022 · 3 comments
Open

CSCPickerState._onSelectedCountry #52

ghost opened this issue May 12, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented May 12, 2022

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):
carbon
carbon (1)

@salvaterra
Copy link

salvaterra commented May 26, 2022

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

@ghost
Copy link
Author

ghost commented Jun 14, 2022

still makeing problem
if you can edit my code will be fine

@Heydran
Copy link

Heydran commented Dec 7, 2022

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.

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

No branches or pull requests

2 participants