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
除非另有说明,否则本网站上的文档反映的是 Dart 3.7.1 版本。页面上次更新于 2025-03-07。 查看源代码 或 报告问题。