unnecessary_getters

Group: Style Guide

Kind: Prefer

Maturity: STABLE

View the Project on GitHub dart-lang/linter

From the style guide:

PREFER using a public final field instead of a private field with a public getter.

If you have a field that outside code should be able to see but not assign to (and you don't need to set it outside of the constructor), a simple solution that works in many cases is to just mark it final.

GOOD:

class Box {
  final contents = [];
}

BAD:

class Box {
  var _contents;
  get contents => _contents;
}