Skip to content

[DISABLED] Lint to prefer using a public final field instead of a private field with a public getter (Style Guide) #57169

@pq

Description

@pq

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions