== Why is this an issue?

In Dart, a setter is a special type of function that is used to set the value of a property on an object. Setters are defined using the `set` keyword followed by the name of the property that the setter is associated with.

To set the property, we simply assign a value to it as if it were a regular property. The setter function is automatically called with the value that we assign to the property.

Functions declared with the `set` keyword can't return any value, so setting any return type other than `void` is a compile-time error. While this is possible to still add `void` return type it is redundant and should be omitted.

[source,dart,diff-id=1,diff-type=noncompliant]
----
class Person {
  String name;
  int birthYear;

  Person(this.name, this.birthYear);

  // Adding a calculated property age
  int get age => currentYear - birthYear;
  void set age(int value) => birthYear = currentYear - value; // Noncompliant
}
----

[source,dart,diff-id=1,diff-type=compliant]
----
class Person {
  String name;
  int birthYear;

  Person(this.name, this.birthYear);

  // Adding a calculated property age
  int get age => currentYear - birthYear;
  set age(int value) => birthYear = currentYear - value;
}
----

== Resources

=== Documentation

* Dart Docs - https://dart.dev/tools/linter-rules/avoid_return_types_on_setters[Dart Linter rule - avoid_return_types_on_setters]
* Dart Docs - https://dart.dev/language/methods#getters-and-setters[Getters and setters]


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Unnecessary return type on a setter.

=== Highlighting

The `void` keyword in the setter declaration.

'''
== Comments And Links
(visible only on this page)

endif::env-github,rspecator-view[]
