Skip to content

Instantly share code, notes, and snippets.

@stobix
Created November 7, 2023 20:07
Show Gist options
  • Save stobix/dc5acf02f0a47d9d02f56f48ff653beb to your computer and use it in GitHub Desktop.
Save stobix/dc5acf02f0a47d9d02f56f48ff653beb to your computer and use it in GitHub Desktop.
Nullable dart bug
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