prefer_const_constructors

Group: style

Maturity: stable

Linter v0.1.30

Since info is static, may be stale
flutter

View all Lint Rules

Using the Linter

PREFER using const for instantiating constant constructors.

If a constructor can be invoked as const to produce a canonicalized instance, it's preferable to do so.

GOOD:

class A {
  const A();
}

void accessA() {
  A a = const A();
}

GOOD:

class A {
  final int x;

  const A(this.x);
}

A foo(int x) => new A(x);

BAD:

class A {
  const A();
}

void accessA() {
  A a = new A();
}