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

Error: Can't use an expression of type 'void Function()?' as a function because it's potentially null. #300

Open
dupuchba opened this issue Jan 5, 2024 · 0 comments

Comments

@dupuchba
Copy link
Contributor

dupuchba commented Jan 5, 2024

When binding a nullable Function property inference should remove the?

(when-some [cb (-> (m/ContextMenuButtonItem .onPressed nil) .-onPressed)]
    (cb))

will generate

final void Function()? some$6054_$AUTO_$1=const f_material.ContextMenuButtonItem(onPressed: null, ).onPressed;
if((null == some$6054_$AUTO_$1)){
return null;
}
final void Function()? cb$1=some$6054_$AUTO_$1;
return cb$1();

Which throws at compile time

Try calling using ?.call instead.
Performing hot reload...                                        
return cb$1();
           ^
Try again after fixing the above error(s).
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

1 participant