Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add super initializer examples #3177

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion lib/src/rules/prefer_asserts_in_initializer_lists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../ast.dart';
const _desc = r'Prefer putting asserts in initializer list.';

const _details = r'''
**DO** put asserts in initializer list for constructors with only asserts in
**DO** put asserts in initializer lists for constructors with only asserts in
their body.

**GOOD:**
Expand All @@ -31,6 +31,31 @@ class A {
}
```

**GOOD:**
```dart
class A {
final int a;
A(this.a);
}

class B extends A {
B(super.a) : assert(a != 0);
}
```

**BAD:**
```dart
class A {
final int a;
A(this.a);
}

class B extends A {
B(super.a) {
assert(a != 0);
pq marked this conversation as resolved.
Show resolved Hide resolved
}
}
```
''';

class PreferAssertsInInitializerLists extends LintRule {
Expand Down