no_runtimeType_toString

Group: style

Maturity: stable

Linter v0.1.110

Since info is static, may be stale

View all Lint Rules

Using the Linter

Calling toString on a runtime type is a non-trivial operation that can negatively impact performance. It's better to avoid it.

BAD:

class A {
  String toString() => '$runtimeType()';
}

GOOD:

class A {
  String toString() => 'A()';
}

This lint has some exceptions where performance is not a problem or where real type information is more important than performance: