assignment_ to_ final
Details about the 'assignment_to_final' diagnostic produced by the Dart analyzer.
'{0}' can't be used as a setter because it's final.
Description
#
The analyzer produces this diagnostic when it finds an invocation of a
setter, but there's no setter because the variable or field with the
same name was declared to be final.
Example
#The following code produces this diagnostic because v is final:
final v = 0;
void f() {
v = 1;
}
Common fixes
#
If you need to be able to set the value of the variable, then remove the
modifier final from the variable:
var v = 0;
void f() {
v = 1;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.