dart-data-plugin
dart-data-plugin copied to clipboard
Generated toString should not use +
Per the example the generated toString looks like this:
@override
String toString() {
return 'Person{' +
' id: $id,' +
' _firstName: $_firstName,' +
' _lastName: $_lastName,' +
' age: $age,' +
' income: $income,' +
'}';
}
Which fails this lint check: https://dart-lang.github.io/linter/lints/prefer_interpolation_to_compose_strings.html
It may not be well known but the + operators are not necessary for concatenating string literals and are the source of the issue. As mentioned here, "Adjacent string literals are concatenated automatically".
So what you should generate is this:
@override
String toString() {
return 'Person{'
' id: $id,'
' _firstName: $_firstName,'
' _lastName: $_lastName,'
' age: $age,'
' income: $income,'
'}';
}