No promotion of nullable type in "if (x?.y ?? false)" #56693
Labels
legacy-area-analyzer
Use area-devexp instead.
triage-automation
See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.
type-enhancement
A request for a change that isn't a bug
I thought there might be an existing issue fort his, but I couldn't find one. Often I find myself writing code like:
However this reports "The property 'length' can't be unconditionally accessed because the receiver can be 'null'". My usual fix is to have an explicit null check:
But this feels a little verbose. Maybe it'd be nice to have a
.isNullOrEmpty
, but that'd have to be known to the analyzer (if I implement it as an extension member, the analyzer wouldn't know it could be promoted).The text was updated successfully, but these errors were encountered: