Having problems with the checkbox widget

hello, i am having problems with the checkbox widget as described in ch06

I can not get the onComplete to work with the code as described and can not figure out why…


@lc0815 where is your onComplete function?

It should be defined in GroceryTile as a type function:

final Function(bool?)? onComplete;

that is exactly where it is…

Please let me know if you want me to upload the GroceryTile flle…

Thanks much…

while posting my images, I noticed the missing ? inisde the (bool) parenthesis and that was the problem.
however, you need to explain why the need for the question marks as I don’t understand why they are need in the first place and I understand it has something to do with null safety, but most of us are newbes and our understanding of DART is just as little as our understanding of FLUTTER.

thanks again

@lc0815 Checkbox widget takes in an OnChanged callback which takes in an optional bool value. This is why there is a ? within the (bool).

required ValueChanged<bool?>? onChanged

You can checkout the checkbox doc for more info!

I think it just comes with practice, and reading the docs to understand why.
https://api.flutter.dev/flutter/material/Checkbox-class.html

But this comes with experience! And now you have it!

1 Like