0

enter image description hereenter image description here

1: I want to use check box but facing this error again and again.. I'm new in flutter what do I do now. https://i.stack.imgur.com/m9PdK.jpg

1 Answers1

0

It seems that to believe the error message that is showing you have mutliple causes:

First the "error getter 'sortFilter' isn't defined means that you either didn't pass the argument or that simply the sortFilter isn't defined in your widget meaning that when you do widget.sortFilter, here sortFilter will be undefined.

Secondly, it appear that for the last error message selectedValue is just not initialized, you certainly put before, the keyword late to that variable and didn't put a value afterward. So try by default giving him true or false and at least you should have this solved.

Anyways, if those solution doesn't not work, please give a better overview or your code especially the widget CarInfoScreen.

Madere
  • 50
  • 6
  • Defined 'sortFilter' but still got same error.. shared that screenshot... Infact I performed another code from YouTube.. it's also getting this error... Didn't get it why this error showing... – AvirupChakraborty05 May 11 '22 at 15:52
  • To believe the screen that you put in the initial question: you are writing widget.sortedFilter. But the problem here is that you do not need to use the keyword widget. You can simply write sortedFilter to get the value that you want. Why is this possible? When you are writing a widget. some variables mean that they are defined as the argument of the widget (in your example : const CarInfoScreen({key? key}): super(key:key); so for using wigdet.sorted filter it should be: final List sortedFilter; const CarInfoScreen({key? key, required this.sortedFilter}): super(key:key); – Madere May 12 '22 at 05:00
  • Finally, here you have defined your sortedFilter List in the second part of the stafulWidget. It means that here it is not variables that is pass through the widget but only variables private to that specific widget and that you can't access it from another widget. So as same as how you are calling listDrop or selected value it will be : sortedFilter[index] and not widget.sortedFilter[index]. I hope this is clearer for you. Do not hesitate if you do not understand to tell me. I'll try to put it in another ways with example. – Madere May 12 '22 at 05:05
  • @AvirupChakraborty05 Did you managed to solve your problem ? – Madere May 16 '22 at 05:55