== Why is this an issue?

Final fields can't be reassigned. There's often a need to declare some fields that aren't intended to be changed. To avoid confusion, such fields should be marked `final` to make their intended use explicit, and to prevent future maintainers from inadvertently changing their use.


== How to fix it

Mark the given field with the `final` modifier.


=== Code examples

==== Noncompliant code example

[source,dart,diff-id=1,diff-type=noncompliant]
----
class Person {
  var _birthYear; // Noncompliant, _birthYear never updated in this class
  var _age = 0;

  Person(this.birthYear);

  void updateAge(int newAge) {
    _age = newAge;
  }
}
----

==== Compliant solution

[source,dart,diff-id=1,diff-type=compliant]
----
class Person {
  final _birthYear;
  var _age = 0;

  Person(this.birthYear);

  void updateAge(int newAge) {
    _age = newAge;
  }
}
----

== Resources

* https://dart.dev/tools/linter-rules/prefer_final_fields[Dart Lint rule]
