Avoid returning this from methods just to enable a fluent interface.
This rule is available as of Dart 2.0.0.
AVOID returning this from methods just to enable a fluent interface.
this from a method is redundant; Dart has a cascade operator which
allows method chaining universally.
this is allowed for:
- methods with a return type different of the current class
- methods defined in parent classes / mixins or interfaces
- methods defined in extensions
var buffer = StringBuffer() .write('one') .write('two') .write('three');
var buffer = StringBuffer() ..write('one') ..write('two') ..write('three');
To enable the
avoid_returning_this under linter > rules in your
linter: rules: - avoid_returning_this