overridden_fields

Group: style

Maturity: stable

Linter v0.1.18

Since info is static, may be stale
recommendedflutter

View all Lint Rules

Using the Linter

DON'T override fields.

Overriding fields is almost always done unintentionally. Regardless, it is a bad practice to do so.

BAD:

class Base {
  Object field = 'lorem';

  Object something = 'change';
}

class Bad1 extends Base {
  @override
  final field = 'ipsum'; // LINT
}

class Bad2 extends Base {
  @override
  Object something = 'done'; // LINT
}

GOOD:

class Base {
  Object field = 'lorem';

  Object something = 'change';
}

class Ok extends Base {
  Object newField; // OK

  final Object newFinal = 'ignore'; // OK
}

GOOD:

abstract class BaseLoggingHandler {
  Base transformer;
}

class LogPrintHandler implements BaseLoggingHandler {
  @override
  Derived transformer; // OK
}