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:
dart
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:
dart
var v = 0;
void f() {
v = 1;
}
本页内容对你有帮助吗?
除非另有说明,文档之所提及适用于 Dart 3.14 版本报告页面问题.