{"slug":"dart-multiline-strings","title":"dart-multiline-strings","summary":"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.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-14T18:30:24.041117Z","repo":{"url":"https://github.com/kevmoo/dash_skills","stars":145,"forks":16,"license":"Apache-2.0","updatedAt":"2026-09-13T01:43:59Z"},"bodyHtml":"<hr>\n<p>name: dart-multiline-strings\ndescription: |-\nGuidelines and best practices for refactoring consecutive prints, single-line\nstring concatenations, and complex output blocks into triple-quoted multi-line\nstring literals (''' or \"\"\") in Dart.\nlicense: Apache-2.0\nkey_features:</p>\n<ul>\n<li>Triple-quoted multiline strings</li>\n<li>Print &amp; concatenation refactoring</li>\n<li>Formatting large text blocks</li>\n</ul>\n<hr>\n<h1>Dart Multi-line Strings</h1>\n<h2>1. When to use this skill</h2>\n<p>Use this skill when:</p>\n<ul>\n<li>Refactoring consecutive <code>print()</code> or <code>stdout.writeln()</code> statements into a\nsingle, cohesive output block.</li>\n<li>Simplifying string literals that span multiple lines, contain embedded\nnewlines (<code>\\n</code>), or use nested indentations.</li>\n<li>Formatting large user-facing text output (like CLI help menus, reports, or\ntemplated messages) to be readable, maintainable, and performant.</li>\n</ul>\n<h3>When NOT to use (Abstention Guardrails)</h3>\n<p>Do NOT refactor to multiline strings when:</p>\n<ul>\n<li><strong>Short, Single-Line Outputs</strong>: Strings that comfortably fit on a single line\n(&lt;80 chars) without embedded newlines.</li>\n<li><strong>Localized String Catalogs</strong>: Strings that are looked up from localization\nbundles (e.g. <code>intl</code>, ARB files), where line breaks or formatting must conform\nto external translation tooling.</li>\n<li><strong>Raw Query Strings with Strict Whitespace Semantics</strong>: Protocol strings,\nstrict CSV rows, or queries where indentation whitespace inside triple quotes\nwould alter payload semantics or introduce unintended leading spaces.</li>\n<li><strong>Streaming or Incremental I/O</strong>: Progress bars, spinners, or interactive\nconsole streams where individual writes occur with delays or flushing between\nlines.</li>\n</ul>\n<h2>Discovery</h2>\n<p>To find candidate code blocks for multi-line string refactoring:</p>\n<ul>\n<li>Look for multiple back-to-back <code>print()</code> or <code>stdout.writeln()</code> calls inside a\nfunction, especially inside loops, console views, or CLI controllers.</li>\n<li>Look for single-line strings heavily loaded with <code>\\n</code> escape sequences.</li>\n<li>Look for multiple string concatenations using the <code>+</code> operator or adjacent\nstring literal splits that are meant to represent multi-line outputs.</li>\n</ul>\n<h2>2. Guidelines</h2>\n<h3>Combine Consecutive Outputs</h3>\n<p>Instead of calling <code>print()</code> repeatedly for a multi-line output, group the\ncontents into a single triple-quoted string literal: <code>print('''...''')</code>.</p>\n<h3>Explicit and Clean Alignment</h3>\n<p>In a triple-quoted literal, the exact spacing and formatting inside the quotes\nare preserved. Use this to specify indentation levels visually instead of using\nmanually padded space prefixes (e.g., <code>'    '</code>).</p>\n<h3>Remove Empty Print Calls</h3>\n<p>If there are empty <code>print()</code> or <code>print('')</code> statements serving as vertical\nseparators between output segments, replace them by letting the trailing newline\nof a multi-line string block handle the separation naturally.</p>\n<h3>Handling the First Newline</h3>\n<p>If the opening triple-quote is immediately followed by a newline, the compiler\ndiscards it.</p>\n<ul>\n<li>If you do <strong>not</strong> want a leading blank line, start the string content on a\nfresh line in the source code for clean layout.</li>\n<li>If you <strong>do</strong> want a leading blank line in the output, leave an extra empty\nline inside the triple-quoted block, or use <code>\\n</code> explicitly at the beginning:\n<pre><code>print('''\n\nThis starts with one blank line above it.''');\n</code></pre>\n</li>\n</ul>\n<h3>Handling the Trailing Newline &amp; <code>print()</code></h3>\n<p><code>print()</code> automatically appends a trailing newline to the printed output.</p>\n<ul>\n<li>If you place the closing <code>'''</code> on a new line (<code>\\n''');</code>), an extra trailing\nblank line will be printed.</li>\n<li>To avoid unintended trailing blank lines, place the closing triple-quotes\nimmediately after the final character:\n<pre><code>// ✅ Emits standard output with no extra trailing empty line:\nprint('''\nHeader\nContent''');\n</code></pre>\n</li>\n</ul>\n<h3>Avoiding Ghost Blank Lines in Conditional Interpolations</h3>\n<p>When injecting optional content via interpolation (<code>${condition ? '...' : ''}</code>),\nplacing the <code>${...}</code> on its own line leaves behind its enclosing newline when\nthe condition evaluates to <code>''</code>, producing an empty blank line in the output.</p>\n<ul>\n<li>Include the leading newline <em>inside</em> the conditional string literal so the\nnewline only renders when the content is present:\n<pre><code>// ✅ Clean conditional rendering without ghost blank lines:\nprint('''\nBranch Details:\n    Name: $branch${hasWarning ? '\\n    WARNING: $warningMessage' : ''}''');\n</code></pre>\n</li>\n</ul>\n<h3>80-Character Line Limit Exemption</h3>\n<p>The <code>lines_longer_than_80_chars</code> lint rule <strong>automatically ignores</strong> lines\ninside multiline string literals. You can write long lines inside triple-quotes\nwithout triggering linter warnings or being forced to break them up.</p>\n<h3>Dynamic Switch Expressions inside Interpolation</h3>\n<p>Leverage Dart 3 switch expressions directly inside string interpolations to\ndynamically select and inject optional lines, conditional labels, or helper\ninstructions. This avoids cluttering the surrounding code with imperatively\nconstructed strings or multiple <code>if</code> statements:</p>\n<pre><code>print('''\nStatus: ${status.isSuccess ? 'PASS' : 'FAIL'}${switch (status) {\n  Status.failed =&gt; '\\nError details: $errorMessage',\n  _ =&gt; '',\n}}''');\n</code></pre>\n<h2>3. Examples</h2>\n<h3>Refactoring Consecutive Prints with Indentation</h3>\n<p><strong>Avoid:</strong></p>\n<pre><code>void printGerritView(String branch, String desc, bool hasConflicts) {\n  print('Branch Details:');\n  print('    Name:        ' + branch);\n  print('    Description: ' + desc);\n  print('');\n  if (hasConflicts) {\n    print('    WARNING: This branch has conflicts.');\n    print('    Run `git merge origin/main` to resolve.');\n  }\n}\n</code></pre>\n<p><strong>Prefer:</strong></p>\n<pre><code>void printGerritView(String branch, String desc, bool hasConflicts) {\n  print('''\nBranch Details:\n    Name:        $branch\n    Description: $desc${hasConflicts ? '''\n\n    WARNING: This branch has conflicts.\n    Run `git merge origin/main` to resolve.''' : ''}''');\n}\n</code></pre>\n","files":[{"path":"evals/evals.json","sizeBytes":3620,"isText":true},{"path":"SKILL.md","sizeBytes":5837,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-14T18:30:30.434678Z","sha256":"8F3929FCB72F01E4AECF817B6253A2C6EDF8EAE4D0C9297E6032D1D73B5A2918","sizeBytes":3806},"review":null,"source":{"repositoryUrl":"https://github.com/kevmoo/dash_skills","path":"skills/dart-multiline-strings","license":"Apache-2.0","commit":"38dce749552380f618791d05686494d2a60c593a","subtreeSha":"6D166FB34627A16DD57F815000FAF316531222E599637D7F9493E5391A5C17C9","lastSyncedAt":"2026-09-18T12:20:11.187933Z"},"reviewedAt":"2026-09-14T18:30:52.561243Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/kevmoo/dash_skills/tree/main/skills/dart-multiline-strings"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kevmoo-dash-skills@llmmart"},{"target":"git","command":"git clone https://github.com/kevmoo/dash_skills.git"}]}