Skip to content

shorthand_inside_shorthand

Reports a dot-shorthand call passed as an argument to another dot-shorthand call, as in .all(.circular(8)). Write out one of the two types.

Tier
advisory
Scope
Dart
Lowest preset
strict
Fix
none

A static method or constructor call written as a dot shorthand that is an argument, positional or named, of another call written as one: .all(.circular(8)). The violation covers the inner call.

It does not report:

  • a shorthand that only names a value: .center, .zero;
  • one level of shorthand;
  • a shorthand inside a function literal passed as an argument.

Each shorthand takes its type from the parameter it is passed to. With two in a row, no type is named on the line, and a reader has to look up two signatures.

Violating
Corners round() => .all(.circular(8));
Corrected
Corners round() => .all(Radius.circular(8));

Set under the assay: key of the project’s root analysis_options.yaml.

Rule parameter Default Effect
enabled true false switches the rule off for the whole project.
exclude [] Path globs where the rule is silent.

Write why on the line directly above the suppression:

// Why it stays as written here.
// ignore: assay/shorthand_inside_shorthand

// ignore_for_file: assay/shorthand_inside_shorthand silences it in a whole file, and // ignore: shorthand_inside_shorthand without the prefix works too. See Suppressions.