prefer_adjacent_string_concatenation
使用相鄰字串來串連字串字面值。
詳細資訊
#請務必 使用相鄰字串來串連字串字面值。
不良範例
dart
raiseAlarm(
'ERROR: Parts of the spaceship are on fire. Other ' +
'parts are overrun by martians. Unclear which are which.');
良好範例
dart
raiseAlarm(
'ERROR: Parts of the spaceship are on fire. Other '
'parts are overrun by martians. Unclear which are which.');
啟用
#若要啟用 prefer_adjacent_string_concatenation
規則,請在您的 analysis_options.yaml
檔案中的 linter > rules 下新增 prefer_adjacent_string_concatenation
analysis_options.yaml
yaml
linter:
rules:
- prefer_adjacent_string_concatenation
如果您改為使用 YAML map 語法來設定 linter 規則,請在 linter > rules 下新增 prefer_adjacent_string_concatenation: true
analysis_options.yaml
yaml
linter:
rules:
prefer_adjacent_string_concatenation: true
除非另有說明,否則本網站上的文件反映 Dart 3.7.1 版本。頁面最後更新於 2025-03-07。 檢視原始碼 或 回報問題。