wrong_number_of_parameters_for_setter
Setters must declare exactly one required positional parameter.
Description
#The analyzer produces this diagnostic when a setter is found that doesn't declare exactly one required positional parameter.
Examples
#The following code produces this diagnostic because the setter s
declares two required parameters:
dart
class C {
set s(int x, int y) {}
}
The following code produces this diagnostic because the setter s
declares one optional parameter:
dart
class C {
set s([int? x]) {}
}
Common fixes
#Change the declaration so that there's exactly one required positional parameter:
dart
class C {
set s(int x) {}
}
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.