Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 0fc1d28

Browse files
committed
whoops fields
1 parent 31bc38c commit 0fc1d28

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/src/rules/prefer_void_to_null.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ class _Visitor extends SimpleAstVisitor<void> {
140140
return;
141141
}
142142

143-
if (parent is VariableDeclarationList && node == parent.type) {
143+
if (parent is VariableDeclarationList &&
144+
node == parent.type &&
145+
parent.parent is! FieldDeclaration) {
144146
// We should not recommend to use `void` for local or top-level variables.
145147
return;
146148
}

test_data/rules/prefer_void_to_null.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class F implements E {
5252
}
5353

5454
void void_; // OK
55-
Null null_; // LINT
56-
core.Null core_null; // LINT
5755
Future<void>? future_void; // OK
5856
Future<Null>? future_null; // LINT
5957
Future<core.Null>? future_core_null; // LINT
@@ -72,8 +70,6 @@ void Function(Future<Null>)? voidFunctionFutureNull; // LINT
7270

7371
usage() {
7472
void void_; // OK
75-
Null null_; // LINT
76-
core.Null core_null; // LINT
7773
Future<void>? future_void; // OK
7874
Future<Null> future_null; // LINT
7975
Future<core.Null> future_core_null; // LINT
@@ -152,8 +148,6 @@ class AsMembers {
152148

153149
void usage() {
154150
void void_; // OK
155-
Null null_; // LINT
156-
core.Null core_null; // LINT
157151
Future<void>? future_void; // OK
158152
Future<Null> future_null; // LINT
159153
Future<core.Null> future_core_null; // LINT

0 commit comments

Comments
 (0)