sort_child_properties_last
在 widget 例項建立中將子屬性排在最後。
詳情
#在 widget 例項建立中將子屬性排在最後。這提高了可讀性,並且與支援 UI 即程式碼指南的 IDE (例如 IntelliJ) 中的 UI 即程式碼視覺化效果最佳,在這些 IDE 中,按正確順序排列的屬性會清晰地與建構函式呼叫關聯並與子屬性分開。
差
dart
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
mainAxisAlignment: MainAxisAlignment.center,
),
widthFactor: 0.5,
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: _incrementCounter,
tooltip: 'Increment',
),
);好
dart
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
widthFactor: 0.5,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);例外:允許在 child 屬性之後新增包含函式表示式的引數。
啟用
#要啟用 sort_child_properties_last 規則,請在您的 analysis_options.yaml 檔案中的 linter > rules 下新增 sort_child_properties_last
analysis_options.yaml
yaml
linter:
rules:
- sort_child_properties_last如果您改為使用 YAML 對映語法配置 Linter 規則,請在 linter > rules 下新增 sort_child_properties_last: true
analysis_options.yaml
yaml
linter:
rules:
sort_child_properties_last: true