Closed
Description
This tracker is for issues related to: Analyzer.
When I was developing in flutter_tools, I found a weird promotion with the nullability of a local variable.
A simple example for this issue:
void main() {
final String? test;
final List<String> testList = [];
if (1 * 2 == 2) {
test = 'Yes';
} else {
test = null;
}
if (test != null) {
testList.removeWhere((e) => e.contains(test)); // <-- Raises exception.
}
}
I was wondering at this point why the variable cannot be proofed as non-null.