sort_constructors_first
コンストラクタの宣言を他のメンバーよりも前にソートします。
このルールは Dart 2.0 以降で利用可能です。
このルールには、クイックフィックスが利用可能です。
詳細
#推奨 コンストラクタの宣言を他のメンバーよりも前にソートしてください。
悪い例
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
特に明記されていない限り、このサイトのドキュメントは Dart 3.5.3 を反映しています。ページ最終更新日: 2024-07-03。 ソースを表示 または 問題を報告。