in lib/src/rules/prefer_void_to_null.dart [114:156]
void visitNamedType(NamedType node) {
var nodeType = node.type;
if (nodeType == null || !nodeType.isDartCoreNull) {
return;
}
var parent = node.parent;
// Null Function()
if (parent is GenericFunctionType) {
return;
}
// Function(Null)
if (parent is SimpleFormalParameter &&
parent.parent is FormalParameterList &&
parent.parent?.parent is GenericFunctionType) {
return;
}
// <Null>[] or <Null, Null>{}
if (parent is TypeArgumentList) {
var literal = parent.parent;
if (literal is ListLiteral && literal.elements.isEmpty) {
return;
} else if (literal is SetOrMapLiteral && literal.elements.isEmpty) {
return;
}
}
// extension _ on Null {}
if (parent is ExtensionDeclaration) {
return;
}
// https://github.com/dart-lang/linter/issues/2792
if (parent is MethodDeclaration &&
isVoidIncompatibleOverride(parent, node)) {
return;
}
rule.reportLint(node.name);
}