ATTENTION: DO NOT USE THIS FIELD TO ASK SUPPORT QUESTIONS. USE THE PLATFORM CHANNELS FOR THIS. THIS SPACE IS DEDICATED ONLY FOR BUGS DESCRIPTION.
Fill in the template. Issues that do not respect the model will be closed.
Describe the bug
Calling isNull on a null return from a method, causes a exception
To Reproduce
Steps to reproduce the behavior:
1.Utilize isNull on a null return from a method
Expected behavior
A boolean value, not a exception
Screenshots
If applicable, add screenshots to help explain your problem.


Flutter Version:
1.20.4
Getx Version:
3.4.2
Describe on which device you found the bug:
ex: Galaxy A5 - LineageOS (Android 10)
Minimal reproduce code
dynamic method(value){
return findInHiveDatabase(value);
}
main(){
if(method().isNull){
//do a nice thing
}
}
If you want to reproduze in my code:
https://github.com/gumbarros/kepler
lib/views/explore/planetsView.dart
Change line 87 from == null to .isNull
Thank's!, I'll investigate it
@gumbarros this is weird, are you sure you've imported the get package? Your stack trace gave the NoSuchMethodError, a more "correct" stack trace for a method call on null would be:
Uncaught TypeError: Cannot read property 'get$isNull' of nullError: TypeError: Cannot read property 'get$isNull' of null
I see that your project doesn't use static analysis, so maybe you just missed an import?
Is null extension is supposed to be just a syntactic sugar for calls (a.b becomes b(a)), so it's expected to be working even "as part of" null.. here's a snippet:
https://dartpad.dev/3a6a28dedda20872ce97819b9c86c065
Could you put a permalink of your git tree to help? I couldn't find that line on your current git tree..
@Grohden , yes i have imported Get, this bug is very weird.
Here is the permalink of the line.
You need to change == null to .isNull.
@gumbarros downloaded and simulated the issue (nice app design btw)
Here's a snippet about it, basically extensions do not work on dynamic (that is, variables explicitly declared as dynamic)
https://dartpad.dev/f848d908d387ed1597677d2768ae5932
...Aaaand I found an issue closed that explains why: https://github.com/dart-lang/language/issues/708
So.. by munificent comment:
That's correct. They are static extension methods. The intent is that they are purely syntactic sugar for a completely statically-resolved function invocation.
So if the type is dynamic it will not work nor be available, but because the type is dynamic, anything is accepted so dart will not complain of the isNull usage (despite the IDE suggesting it anyway)..
Edit: I would recommend you to enable dart analysis and avoid dynamic as much as possible
Thanks for the return, now I understand because of the DartPad.
The reason the bug happened it's because before the method returned just PlanetData, when it started return StarData too, I needed to change the method to dynamic and the bug happened.
If I add to the two classes a extends UniverseData and put this on the method return type, .isNull will work right?
@gumbarros yes, I've confirmed that changing the return to PlanetData made is null work
Nicee, thanks 馃憤