skills/dart-multiline-strings/SKILL.md
Guidelines and best practices for refactoring consecutive prints, single-line string concatenations, and complex output blocks into triple-quoted multi-line string literals (''' or """) in Dart.
npx skillsauth add kevmoo/dash_skills dart-multiline-stringsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when:
print() or stdout.writeln() statements into a
single, cohesive output block.\n), or use nested indentations.To find candidate code blocks for multi-line string refactoring:
print() or stdout.writeln() calls inside
a function, especially inside loops, console views, or CLI controllers.\n escape sequences.+ operator or adjacent
string literal splits that are meant to represent multi-line outputs.Instead of calling print() repeatedly for a multi-line output, group the
contents into a single triple-quoted string literal: print('''...''').
In a triple-quoted literal, the exact spacing and formatting inside the quotes
are preserved. Use this to specify indentation levels visually instead of using
manually padded space prefixes (e.g., ' ').
If there are empty print() or print('') statements serving as vertical
separators between output segments, replace them by letting the trailing
newline of a multi-line string block handle the separation naturally.
If the opening triple-quote is immediately followed by a newline, the compiler discards it.
\n explicitly at the
beginning:
print('''
This starts with one blank line above it.''');
The lines_longer_than_80_chars lint rule automatically ignores lines inside
multiline string literals. You can write long lines inside triple-quotes without
triggering linter warnings or being forced to break them up.
Leverage Dart 3 switch expressions directly inside string interpolations to
dynamically select and inject optional lines, conditional labels, or helper
instructions. This avoids cluttering the surrounding code with imperatively
constructed strings or multiple if statements:
print('''
Status: ${status.isSuccess ? 'PASS' : 'FAIL'}
${switch (status) {
Status.failed => 'Error details: $errorMessage',
_ => '',
}}''');
Avoid:
void printGerritView(String branch, String desc, bool hasConflicts) {
print('Branch Details:');
print(' Name: ' + branch);
print(' Description: ' + desc);
print('');
if (hasConflicts) {
print(' WARNING: This branch has conflicts.');
print(' Run `git merge origin/main` to resolve.');
}
}
Prefer:
void printGerritView(String branch, String desc, bool hasConflicts) {
print('''
Branch Details:
Name: $branch
Description: $desc
${hasConflicts ? '''
WARNING: This branch has conflicts.
Run `git merge origin/main` to resolve.''' : ''}''');
}
testing
Core concepts and best practices for `package:test`. Covers `test`, `group`, lifecycle methods (`setUp`, `tearDown`), and configuration (`dart_test.yaml`).
testing
Understand and improve test coverage in a Dart package. Helps agents run coverage, interpret results, and identify missed lines.
documentation
Guidelines for maintaining external Dart packages, covering versioning, publishing workflows, and pull request management. Use when updating Dart packages, preparing for a release, or managing collaborative changes in a repository.
tools
Guidelines for using modern Dart features (v3.0 - v3.10) such as Records, Pattern Matching, Switch Expressions, Extension Types, Class Modifiers, Wildcards, Null-Aware Elements, and Dot Shorthands.