csc_picker
csc_picker copied to clipboard
Can't Select Country nor State
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):
Which version are you using ?
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 = "";
i m not able to select any country, city or state.. drop down menu is completely irresponsive
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
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 ?
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
anybody got solution
try this :
onCountryChanged: (value) {
setState(() {
countryValue = value;
});
},
onStateChanged: (value) {
setState(() {
stateValue = value ?? '';
});
},
onCityChanged: (value) {
setState(() {
cityValue = value ?? '';
});
},