內容

prefer_adjacent_string_concatenation

使用相鄰字串來串連字串字面值。

此規則自 Dart 2.0 起可用。

規則集:建議flutter

此規則有可用的快速修正

詳細資料

#

應該使用相鄰字串來串連字串字面值。

錯誤

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