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

Can't Select Country nor State #27

Open
caqlayan opened this issue Jun 20, 2021 · 8 comments
Open

Can't Select Country nor State #27

caqlayan opened this issue Jun 20, 2021 · 8 comments

Comments

@caqlayan
Copy link

Hi. I tried to use that tool but it gave error on picking screen. my code is:

                        layout: Layout.horizontal,
                        flagState: CountryFlag.ENABLE,
                        showStates: true,
                        showCities: true,
                        dropdownDecoration: kBoxDecorationStyle,
                          disabledDropdownDecoration: kBoxDecorationStyle,
                          onCountryChanged: (value) {
                          setState(() {
                            countryValue = value;
                          });
                          },
                        onStateChanged: (value) {
                          setState(() {
                            stateValue = value!;
                          });
                        },
                        onCityChanged: (value) {
                          setState(() {
                            cityValue = value!;
                          });
                        },
                        selectedItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                        dropdownDialogRadius: 15.0,
                        searchBarRadius: 15.0,
                        dropdownItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                      ),

The error is: 
```I/flutter ( 8694): countryChanged 🇦🇱    Albania null
E/flutter ( 8694): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 8694): #0      _RegisterScreenState.build.<anonymous closure>.<anonymous closure> (package:datingapp/screens/register.dart:242:47)
E/flutter ( 8694): #1      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #2      _RegisterScreenState.build.<anonymous closure> (package:datingapp/screens/register.dart:241:27)
E/flutter ( 8694): #3      _CSCPickerState._onSelectedCountry.<anonymous closure> (package:csc_picker/csc_picker.dart:695:36)
E/flutter ( 8694): #4      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #5      _CSCPickerState._onSelectedCountry (package:csc_picker/csc_picker.dart:682:5)
E/flutter ( 8694): #6      _CSCPickerState.countryDropdown.<anonymous closure> (package:csc_picker/csc_picker.dart:837:11)
E/flutter ( 8694): #7      DropdownWithSearch.build.<anonymous closure>.<anonymous closure> (package:csc_picker/dropdown_with_search.dart:53:22)
E/flutter ( 8694): #8      _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter ( 8694): #9      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 8694): <asynchronous suspension>
E/flutter ( 8694): 
@altafc22
Copy link
Owner

Which version are you using ?

@caqlayan
Copy link
Author

Which version are you using ?

Latest. I fixed this bug with changing my String variables to String? for state and city.

  String countryValue = "";
  String? stateValue = "";
  String? cityValue = "";

@rishuriya
Copy link

i m not able to select any country, city or state.. drop down menu is completely irresponsive

@micky113
Copy link

i m not able to select any country, city or state.. drop down menu is completely irresponsive

@caqlayan above comment is right..try using null safety while declaring Strings

@phanindravarma412
Copy link

Hi. I tried to use that tool but it gave error on picking screen. my code is:

                        layout: Layout.horizontal,
                        flagState: CountryFlag.ENABLE,
                        showStates: true,
                        showCities: true,
                        dropdownDecoration: kBoxDecorationStyle,
                          disabledDropdownDecoration: kBoxDecorationStyle,
                          onCountryChanged: (value) {
                          setState(() {
                            countryValue = value;
                          });
                          },
                        onStateChanged: (value) {
                          setState(() {
                            stateValue = value!;
                          });
                        },
                        onCityChanged: (value) {
                          setState(() {
                            cityValue = value!;
                          });
                        },
                        selectedItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                        dropdownDialogRadius: 15.0,
                        searchBarRadius: 15.0,
                        dropdownItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                      ),

The error is: 
```I/flutter ( 8694): countryChanged 🇦🇱    Albania null
E/flutter ( 8694): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 8694): #0      _RegisterScreenState.build.<anonymous closure>.<anonymous closure> (package:datingapp/screens/register.dart:242:47)
E/flutter ( 8694): #1      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #2      _RegisterScreenState.build.<anonymous closure> (package:datingapp/screens/register.dart:241:27)
E/flutter ( 8694): #3      _CSCPickerState._onSelectedCountry.<anonymous closure> (package:csc_picker/csc_picker.dart:695:36)
E/flutter ( 8694): #4      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #5      _CSCPickerState._onSelectedCountry (package:csc_picker/csc_picker.dart:682:5)
E/flutter ( 8694): #6      _CSCPickerState.countryDropdown.<anonymous closure> (package:csc_picker/csc_picker.dart:837:11)
E/flutter ( 8694): #7      DropdownWithSearch.build.<anonymous closure>.<anonymous closure> (package:csc_picker/dropdown_with_search.dart:53:22)
E/flutter ( 8694): #8      _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter ( 8694): #9      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 8694): <asynchronous suspension>
E/flutter ( 8694): 

Did you get any solution ?

@vaishnavi-sangal
Copy link

Hi. I tried to use that tool but it gave error on picking screen. my code is:

                        layout: Layout.horizontal,
                        flagState: CountryFlag.ENABLE,
                        showStates: true,
                        showCities: true,
                        dropdownDecoration: kBoxDecorationStyle,
                          disabledDropdownDecoration: kBoxDecorationStyle,
                          onCountryChanged: (value) {
                          setState(() {
                            countryValue = value;
                          });
                          },
                        onStateChanged: (value) {
                          setState(() {
                            stateValue = value!;
                          });
                        },
                        onCityChanged: (value) {
                          setState(() {
                            cityValue = value!;
                          });
                        },
                        selectedItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                        dropdownDialogRadius: 15.0,
                        searchBarRadius: 15.0,
                        dropdownItemStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
                      ),

The error is: 
```I/flutter ( 8694): countryChanged 🇦🇱    Albania null
E/flutter ( 8694): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 8694): #0      _RegisterScreenState.build.<anonymous closure>.<anonymous closure> (package:datingapp/screens/register.dart:242:47)
E/flutter ( 8694): #1      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #2      _RegisterScreenState.build.<anonymous closure> (package:datingapp/screens/register.dart:241:27)
E/flutter ( 8694): #3      _CSCPickerState._onSelectedCountry.<anonymous closure> (package:csc_picker/csc_picker.dart:695:36)
E/flutter ( 8694): #4      State.setState (package:flutter/src/widgets/framework.dart:1088:30)
E/flutter ( 8694): #5      _CSCPickerState._onSelectedCountry (package:csc_picker/csc_picker.dart:682:5)
E/flutter ( 8694): #6      _CSCPickerState.countryDropdown.<anonymous closure> (package:csc_picker/csc_picker.dart:837:11)
E/flutter ( 8694): #7      DropdownWithSearch.build.<anonymous closure>.<anonymous closure> (package:csc_picker/dropdown_with_search.dart:53:22)
E/flutter ( 8694): #8      _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter ( 8694): #9      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 8694): <asynchronous suspension>
E/flutter ( 8694): 

Did you get any solution ?

same error i got

@Sajidpv
Copy link

Sajidpv commented Oct 13, 2023

anybody got solution

@Hossameddine-khamma
Copy link

Hossameddine-khamma commented Mar 24, 2024

try this :

        onCountryChanged: (value) {
          setState(() {
            countryValue = value;
          });
        },

        onStateChanged: (value) {
          setState(() {
            stateValue = value ?? '';
          });
        },

        onCityChanged: (value) {
          setState(() {
            cityValue = value ?? '';
          });
        },

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

8 participants