prefer_const_literals_to_create_immutables

Group: style

Maturity: stable

Dart SDK: >= 2.0.0 • (Linter v0.1.43)

Since info is static, may be stale

View all Lint Rules

Using the Linter

PREFER using const for instantiating list, map and set literals used as parameters in immutable class instantiations.

BAD:

@immutable
class A {
  A(this.v);
  final v;
}

A a1 = new A([1]);
A a2 = new A({});

GOOD:

A a1 = new A(const [1]);
A a2 = new A(const {});