Created
October 2, 2020 17:21
-
-
Save Grohden/f848d908d387ed1597677d2768ae5932 to your computer and use it in GitHub Desktop.
Snippet showing method extension on dynamic with error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
dynamic getA(){ | |
return null; | |
} | |
} | |
extension IsNull on dynamic { | |
bool get isNull => this == null; | |
} | |
void main() { | |
var foo = Foo(); | |
print(foo.getA().isNull); | |
foo = null; | |
foo.isNull; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment