avoid_positional_boolean_parameters
Avoid positional boolean parameters.
This rule is available as of Dart 2.0.
Details
#From Effective Dart:
AVOID positional boolean parameters.
Positional boolean parameters are a bad practice because they are very ambiguous. Using named boolean parameters is much more readable because it inherently describes what the boolean value represents.
BAD:
dart
Task(true);
Task(false);
ListBox(false, true, true);
Button(false);
GOOD:
dart
Task.oneShot();
Task.repeating();
ListBox(scroll: true, showScrollbars: true);
Button(ButtonState.enabled);
Usage
#To enable the avoid_positional_boolean_parameters
rule,
add avoid_positional_boolean_parameters
under linter > rules in your
analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- avoid_positional_boolean_parameters
除非另有说明,文档之所提及适用于 Dart 3.5.3 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。