Created with <3 with dartpad.dev.
Created
November 7, 2023 20:07
-
-
Save stobix/dc5acf02f0a47d9d02f56f48ff653beb to your computer and use it in GitHub Desktop.
Nullable dart bug
This file contains 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
void main() { | |
String? x = test(null); | |
} | |
A test<A>(A a) => | |
switch((A,a.runtimeType)){ | |
(String,Null) => (){print("found nullable string"); return a;}(), | |
(String,_) => (){print("found nullable string"); return a;}(), | |
(String?,_) => (){print("found nullable string"); return a;}(), | |
(Type(),_) => (){print("failed to find nullable string for $A"); return a;}(), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment