assignment_to_final_no_setter
There isn't a setter named '{0}' in class '{1}'.
Description
#The analyzer produces this diagnostic when a reference to a setter is found; there is no setter defined for the type; but there is a getter defined with the same name.
Example
#The following code produces this diagnostic because there is no setter named x
in C
, but there is a getter named x
:
dart
class C {
int get x => 0;
set y(int p) {}
}
void f(C c) {
c.x = 1;
}
Common fixes
#If you want to invoke an existing setter, then correct the name:
dart
class C {
int get x => 0;
set y(int p) {}
}
void f(C c) {
c.y = 1;
}
If you want to invoke the setter but it just doesn't exist yet, then declare it:
dart
class C {
int get x => 0;
set x(int p) {}
set y(int p) {}
}
void f(C c) {
c.x = 1;
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.