目录

annotate_redeclares

目录

Annotate redeclared members.

This rule is currently experimental and available as of Dart 3.2.

This rule has a quick fix available.

Details

#

DO annotate redeclared members.

This practice improves code readability and helps protect against unintentionally redeclaring members or being surprised when a member ceases to redeclare (due for example to a rename refactoring).

BAD:

dart
class C {
  void f() { }
}

extension type E(C c) implements C {
  void f() {
    ...
  }
}

GOOD:

dart
import 'package:meta/meta.dart';

class C {
  void f() { }
}

extension type E(C c) implements C {
  @redeclare
  void f() {
    ...
  }
}

Usage

#

To enable the annotate_redeclares rule, add annotate_redeclares under linter > rules in your analysis_options.yaml file:

analysis_options.yaml
yaml
linter:
  rules:
    - annotate_redeclares