@@ -13,14 +13,25 @@ class RemoveInitializer extends ResolvedCorrectionProducer {
13
13
@override
14
14
final CorrectionApplicability applicability;
15
15
16
+ /// If true, remove the `late` keyword.
17
+ final bool _removeLate;
18
+
16
19
/// Initialize a newly created instance that can't apply bulk and in-file
17
20
/// fixes.
18
21
RemoveInitializer ({required super .context})
19
- : applicability = CorrectionApplicability .singleLocation;
22
+ : applicability = CorrectionApplicability .singleLocation,
23
+ _removeLate = true ;
20
24
21
25
/// Initialize a newly created instance that can apply bulk and in-file fixes.
22
26
RemoveInitializer .bulkFixable ({required super .context})
23
- : applicability = CorrectionApplicability .automatically;
27
+ : applicability = CorrectionApplicability .automatically,
28
+ _removeLate = true ;
29
+
30
+ /// Initialize a newly created instance that can't apply bulk and in-file
31
+ /// fixes and will not remove the `late` keyword if present.
32
+ RemoveInitializer .notLate ({required super .context})
33
+ : applicability = CorrectionApplicability .singleLocation,
34
+ _removeLate = false ;
24
35
25
36
@override
26
37
FixKind get fixKind => DartFixKind .REMOVE_INITIALIZER ;
@@ -53,7 +64,7 @@ class RemoveInitializer extends ResolvedCorrectionProducer {
53
64
);
54
65
});
55
66
// Delete the `late` keyword if present.
56
- if (variable.isLate) {
67
+ if (_removeLate && variable.isLate) {
57
68
var parent = node.parent;
58
69
if (parent != null ) {
59
70
await builder.addDartFileEdit (file, (builder) {
0 commit comments