目录

prefer_interpolation_to_compose_strings

Use interpolation to compose strings and values.

此规则自 Dart 2.0 版本起可用。

_规则集:recommended , flutter _

此规则提供 快速修复

详情

#

PREFER using interpolation to compose strings and values.

Using interpolation when composing strings and values is usually easier to write and read than concatenation.

BAD:

dart
'Hello, ' + person.name + ' from ' + person.city + '.';

GOOD:

dart
'Hello, ${person.name} from ${person.city}.'

使用方法

#

要启用 prefer_interpolation_to_compose_strings 规则,请在你的 analysis_options.yaml 文件中,在 linter > rules 下添加 prefer_interpolation_to_compose_strings

analysis_options.yaml
yaml
linter:
  rules:
    - prefer_interpolation_to_compose_strings