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

The argument type 'void Function(bool)' can't be assigned to the parameter type 'void Function(bool?)?' #42

Open
Shubham-Narkhede opened this issue Sep 14, 2021 · 3 comments

Comments

@Shubham-Narkhede
Copy link

Hi i'm using this library and when I integret it with my code then it gives this type of error i dont knw why im getting this please help mi.

The argument type 'void Function(bool)' can't be assigned to the parameter type 'void Function(bool?)?'

     onSelectChanged: (bool value) {
                  if (dessert.selected != value) {
                    setState(() {
                      dessert.selected = value;
                    });
                  }
                },
@jayjah
Copy link

jayjah commented Nov 3, 2021

@Shubham-Narkhede The problem is the boolean, which get's passed into your function, it may be null.

Reason for that is the following code:

onChanged: (bool? value) {
                                            setState(() {
                                              widget.rows[index].onSelectChanged!(value);
                                            });
                                          },

Look here for reference: data_tables

So you're code must look like the following:

onSelectChanged: (bool? value) {
                  if (dessert.selected != value) {
                    setState(() {
                      dessert.selected = value;
                    });
                  }
                },

@rodydavis
Copy link
Owner

Could you open a PR?

@jayjah
Copy link

jayjah commented Nov 4, 2021

@rodydavis do you mean to make this one explizit not-nullable? So that the version off @Shubham-Narkhede is valid?

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

3 participants