prefer_interpolation_to_compose_strings
Use interpolation to compose strings and values.
Description
#The analyzer produces this diagnostic when string literals and computed strings are being concatenated using the +
operator, but string interpolation would achieve the same result.
Example
#The following code produces this diagnostic because the String s
is concatenated with other strings using the +
operator:
dart
String f(String s) {
return '(' + s + ')';
}
Common fixes
#Use string interpolation:
dart
String f(List<String> l) {
return '(${l[0]}, ${l[1]})';
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.