Last active
July 8, 2020 10:02
-
-
Save IchordeDionysos/6de875a40e252fe38f3273c30edcb725 to your computer and use it in GitHub Desktop.
Null check on class members not considered for NNBD
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() { | |
Example example = Example(); | |
String? prop; | |
final list = [ | |
if (example.prop != null) | |
// Guaranteed to be not-null, but I still have to force it to be not null | |
// Only this would work: | |
// generateString(example.prop!), | |
// This does not work: | |
generateString(example.prop), | |
// However this does work: | |
if (prop != null) | |
generateString(prop), | |
]; | |
print(list); | |
} | |
class Example { | |
String? prop; | |
} | |
String generateString(String prop) { | |
return 'prop: $prop'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment