Skip to content

Commit

Permalink
add super initializer example (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
pq authored Jan 24, 2022
1 parent 594ed4b commit c4ba590
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/src/rules/tighten_type_of_initializing_formals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const _desc = r'Tighten type of initializing formal.';

const _details = r'''
Tighten type of initializing formal if a non-null assert exists. This allows the
type system to catch problems rather than have them only be caught at run-time.
Tighten the type of an initializing formal if a non-null assert exists. This
allows the type system to catch problems rather than have them only be caught at
run-time.
**BAD:**
```dart
Expand All @@ -29,12 +30,20 @@ class A {
**GOOD:**
```dart
class A {
A.c1(String this.p) : assert(p != null);
A.c1(String this.p);
A.c2(this.p);
final String? p;
}
```
class B {
String? b;
A(this.b);
}
class C extends B {
B(String super.b);
}
```
''';

class TightenTypeOfInitializingFormals extends LintRule {
Expand Down

0 comments on commit c4ba590

Please sign in to comment.