boolean_prefixes

SeverityQuick FixOptions
Info

Details

DO prefix boolean variables, functions and getters with specific verbs.

see: effective-dart

Default valid prefixes:

  • is
  • are
  • was
  • were
  • has
  • have
  • had
  • can
  • should
  • will
  • do
  • does
  • did
Bad
class Point {
  final double x;
  final double y;

  const Point(this.x, this.y);

  bool get origin => x == 0 && y == 0;

  bool samePoint(Point other) => x == other.x && y == other.y;
}
Good
class Point {
  final double x;
  final double y;

  const Point(this.x, this.y);

  bool get isOrigin => x == 0 && y == 0;

  bool isSamePoint(Point other) => x == other.x && y == other.y;
}

Usage

To enable the boolean_prefixes rule, add boolean_prefixes under custom_lint > rules in your analysis_options.yaml file:

custom_lint:
  rules:
    - boolean_prefixes

Options

OptionTypeDescriptionDefault Value
valid_prefixesList<String>A list of valid prefixes.[]

To configure the list of valid prefixes, add a list of strings to the valid_prefixes option:

custom_lint:
  rules:
    - boolean_prefixes:
      valid_prefixes: ['is', 'has']