sort_constructors_first
将构造函数声明排在其他成员之前。
详情
#务必将构造函数声明排在其他成员之前。
不推荐
dart
abstract class Visitor {
double value;
visitSomething(Something s);
Visitor();
}
推荐
dart
abstract class Animation<T> {
const Animation(this.value);
double value;
void addListener(VoidCallback listener);
}
启用
#要启用 sort_constructors_first
规则,请在你的 analysis_options.yaml
文件中 linter > rules 下添加 sort_constructors_first
analysis_options.yaml
yaml
linter:
rules:
- sort_constructors_first
如果你使用 YAML 映射语法配置 linter 规则,请在 linter > rules 下添加 sort_constructors_first: true
analysis_options.yaml
yaml
linter:
rules:
sort_constructors_first: true