avoid_field_initializers_in_const_classes

Group: style

Maturity: stable

Linter v0.1.48

Since info is static, may be stale

View all Lint Rules

Using the Linter

AVOID field initializers in const classes.

Instead of final x = const expr;, you should write get x => const expr; and not allocate a useless field. As of April 2018 this is true for the VM, but not for code that will be compiled to JS.

BAD:

class A {
  final a = const [];
  const A();
}

GOOD:

class A {
  get a => const [];
  const A();
}