跳到主要内容

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 映射语法来配置 linter 规则,请在 linter > rules 下添加 prefer_adjacent_string_concatenation: true

analysis_options.yaml
yaml
linter:
  rules:
    prefer_adjacent_string_concatenation: true