Skip to content

Instantly share code, notes, and snippets.

@IchordeDionysos
Last active July 8, 2020 10:02
Show Gist options
  • Save IchordeDionysos/6de875a40e252fe38f3273c30edcb725 to your computer and use it in GitHub Desktop.
Save IchordeDionysos/6de875a40e252fe38f3273c30edcb725 to your computer and use it in GitHub Desktop.
Null check on class members not considered for NNBD
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