dart-multiline-strings
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.
What this skill does
# Dart Multi-line Strings
## 1. When to use this skill
Use this skill when:
- Refactoring consecutive `print()` or `stdout.writeln()` statements into a
single, cohesive output block.
- Simplifying string literals that span multiple lines, contain embedded
newlines (`\n`), or use nested indentations.
- Formatting large user-facing text output (like CLI help menus, reports, or
templated messages) to be readable, maintainable, and performant.
## Discovery
To find candidate code blocks for multi-line string refactoring:
- Look for multiple back-to-back `print()` or `stdout.writeln()` calls inside
a function, especially inside loops, console views, or CLI controllers.
- Look for single-line strings heavily loaded with `\n` escape sequences.
- Look for multiple string concatenations using the `+` operator or adjacent
string literal splits that are meant to represent multi-line outputs.
## 2. Guidelines
### Combine Consecutive Outputs
Instead of calling `print()` repeatedly for a multi-line output, group the
contents into a single triple-quoted string literal: `print('''...''')`.
### Explicit and Clean Alignment
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., `' '`).
### Remove Empty Print Calls
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.
### Handling the First Newline
If the opening triple-quote is immediately followed by a newline, the compiler
discards it.
- If you do **not** want a leading blank line, start the string content on a
fresh line in the source code for clean layout.
- If you **do** want a leading blank line in the output, leave an extra empty
line inside the triple-quoted block, or use `\n` explicitly at the
beginning:
```dart
print('''
This starts with one blank line above it.''');
```
### 80-Character Line Limit Exemption
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.
### Dynamic Switch Expressions inside Interpolation
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:
```dart
print('''
Status: ${status.isSuccess ? 'PASS' : 'FAIL'}
${switch (status) {
Status.failed => 'Error details: $errorMessage',
_ => '',
}}''');
```
## 3. Examples
### Refactoring Consecutive Prints with Indentation
**Avoid:**
```dart
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:**
```dart
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.''' : ''}''');
}
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.