Dart: How to implement a similar situation like "when hashcode() is overridden, ==() should also be overridden"?

121 Views Asked by At

When either hashCode() or == operator is overridden in a class, the dart analyzer warns, saying that the other method should also be overridden.

Can I implement a similar case on other methods? Or is this feature a special case provided by Dart Analyzer?

For exmaple,

class A {
  void method1() {}

  void method2() {}
}

class B extends A {
  @override
  void method1() {}
}

At this point I want to produce a warning that class B should also override method2(). Is that possible?

1

There are 1 best solutions below

0
On BEST ANSWER

What you are seeing is a linter rule. The dart analyzer implements a bunch of these which you can view here or check out just that specific rule.
While you can customize static analysis for your project, as far as I can tell support for custom linting rules is still not available (yet).