Write, review, or refactor correct, idiomatic Dart code. Use for Dart source, packages, snippets, tests, public APIs, documentation examples, and modern language features. Pair with the write-flutter skill for Flutter-specific concerns.
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Produce clear, correct, idiomatic Dart.
Reference the write-technical-docs skill when authoring
explanatory prose and documentation comments.
Two principles guide the code rules:
In the references, DO and DON'T are near-absolute, PREFER and AVOID are strong defaults, and CONSIDER requires judgment.
analysis_options.yaml files for additional requirements.pubspec.yaml.
The installed SDK might support syntax that the package doesn't.Apply these high-frequency rules while writing.
UpperCamelCase for types and extensions,
lowerCamelCase for members, variables, and constants,
and lowercase_with_underscores for files, packages, and import prefixes.
For example, write defaultTimeout, never DEFAULT_TIMEOUT.isEmpty and canClose.pageCount.removeLast().
Never prefix an accessor with get.Object? to mean "any value".
Reserve dynamic for deliberately disabling static checking.final over var for variables that aren't reassigned,
including locals, fields, and top-level variables.const.late when initialization genuinely happens after construction
or lazily on first access.
If code needs to ask whether initialization happened,
use a nullable type and check for null instead.null.
Use a nullable return type only when absence is a real state
that callers must distinguish.default or _ case,
so adding a new case becomes a compile-time error everywhere it's handled.on.
Never discard errors without handling them.
Use rethrow, not throw e.
Throw Error subtypes only for programming bugs and
don't catch them for recovery.resize(width: 320, keepAspect: true).async and await over raw .then() chains,
and account for every returned Future.
Await or return the future.
If an operation is intentionally detached,
wrap it in unawaited(operation())
and make its error behavior deliberate.Use modern features when they improve type safety or remove boilerplate without obscuring the example. Check the package's SDK constraint, then read Modern Dart idioms for version requirements and examples.
When an SDK and project are available,
format changed files, run dart analyze, and run the relevant tests.
Use flutter test instead of dart test for Flutter code.
For standalone snippets, check the relevant reference and
compile them when practical.
Read only the references relevant to the code you're writing or reviewing:
flutter/website
3667d0e
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.