Skip to main content

missing-use-result-annotation

added in: 1.16.0
⚙️🛠

Warns when a method or function declaration is missing the @useResult annotation.

@useResult annotation is used by the Dart analyzer to indicate that the value obtained by invoking a declaration should be used.

note

This rule requires configuration in order to highlight any issues.

⚙️ Config

Set type-pattern (default is empty) to configure a regular expression for return types that should have the annotation.

Set methods (default is empty) to configure a list of declarations that should have the annotation.

dart_code_metrics:
...
rules:
...
- missing-use-result-annotation:
type-pattern: ^Either<
methods:
- toJson

Example

❌ Bad:

Either<Left, Right> either() => ...; // LINT

✅ Good:


Either<Left, Right> either() => ...;