Index: pkg/analyzer/lib/src/task/strong/checker.dart |
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart |
index 8f2f12cf4926712a2392ae339ff6f5ce2cbaa234..b20d702e71f4f1c4fa53b9c4974e48b22260857e 100644 |
--- a/pkg/analyzer/lib/src/task/strong/checker.dart |
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart |
@@ -629,6 +629,20 @@ class CodeChecker extends RecursiveAstVisitor { |
} |
@override |
+ Object visitVariableDeclaration(VariableDeclaration node) { |
+ if (!node.isConst && |
+ !node.isFinal && |
+ node.initializer == null && |
+ rules.isNonNullableType(node?.element?.type)) { |
+ _recordMessage( |
+ node, |
+ StaticTypeWarningCode.NON_NULLABLE_FIELD_NOT_INITIALIZED, |
+ [node.name, node?.element?.type]); |
+ } |
+ return super.visitVariableDeclaration(node); |
+ } |
+ |
+ @override |
void visitWhileStatement(WhileStatement node) { |
checkBoolean(node.condition); |
node.visitChildren(this); |