avoid-unused-after-null-check
Warns when a variable is checked for non-nullable value, but is not used within the condition or then branch.
info
This rule triggers only for cases when there is a potential place for an unused variable (e.g. matching type or invocation target).
Example
❌ Bad:
void fn(String value) {
final String? myNullableValue = 'hello';
if (myNullableValue != null) {
print(value); // LINT
}
}
✅ Good:
void fn(String value) {
final String? myNullableValue = 'hello';
if (myNullableValue != null) {
print(myNullableValue);
}
}