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