cascade_invocations
Cascade consecutive method invocations on the same reference.
This rule is available as of Dart 2.0.0.
This rule has a quick fix available.
Details
DO Use the cascading style when successively invoking methods on the same reference.
BAD:
SomeClass someReference = SomeClass();
someReference.firstMethod();
someReference.secondMethod();
BAD:
SomeClass someReference = SomeClass();
...
someReference.firstMethod();
someReference.aProperty = value;
someReference.secondMethod();
GOOD:
SomeClass someReference = SomeClass()
..firstMethod()
..aProperty = value
..secondMethod();
GOOD:
SomeClass someReference = SomeClass();
...
someReference
..firstMethod()
..aProperty = value
..secondMethod();
Usage
To enable the cascade_invocations
rule,
add cascade_invocations
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- cascade_invocations