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
:
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:
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:
class C {
int get x => 0;
set x(int p) {}
set y(int p) {}
}
void f(C c) {
c.x = 1;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.