== Why is this an issue?

The value of a ``++final++``or `const` variable can't be changed. In Dart `const` declares a compile-time constant, which will be computed during compilation and this might improve performance. So in general it is recommended to use `const`, where possible. In Dart it is also possible to use `const` to create constant values, as well as to declare constructors that create constant values. `final` declarations initialized with such values should be `const`.

=== Noncompliant code example

[source,dart,diff-id=1,diff-type=noncompliant]
----
final i = 1000; // Noncompliant
final ints = const [1, 2, 3]; // Noncompliant

class MyClass {
  static final name = "NAME"; // Noncompliant
}
----


=== Compliant solution

[source,dart,diff-id=1,diff-type=compliant]
----
const i = 1000;
const ints = [1, 2, 3]; // const after assignment can be omitted

class MyClass {
  static const name = "NAME";
}
----

== Resources

* Dart Docs - https://dart.dev/tools/linter-rules/prefer_const_declarations[Dart Linter rule - prefer_const_declarations]
* Dart Docs - https://dart.dev/language/variables#final-and-const[Final and const]

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Use 'const' for final variables initialized to a constant value.

=== Highlighting

declaration

endif::env-github,rspecator-view[]
