dimitriremoiville/cc-mobile/dart-style
Claude Code and agent skill by dimitriremoiville/cc-mobile
- community
Checking that the SKILL.md file is still in the repository.
Dart 3 idioms and conventions for this project — null safety, sealed classes and pattern matching, records, async cleanup, equality via freezed, and when to use each keyword. Load whenever writing or reviewing Dart.
Install
npx vskill@latest install dimitriremoiville/cc-mobile/dart-styleSKILL.md
The same SKILL.md was published earlier as dimitriremoiville/cc-mobile/dart-style.
Dart style
Opinionated defaults for this codebase. These complement the analyzer rules, not replace them.
Naming
- Files:
snake_case.dart. One public type per file is the default. - Types:
UpperCamelCase. Variables & functions:lowerCamelCase. Constants:lowerCamelCase(Dart doesn't use SCREAMING_CASE). - Private identifiers start with
_(Dart's only access modifier). Dtosuffix on wire types; entities use the plain noun (User, notUserEntity).
Immutability
finaleverywhere you can.conston constructors whenever values allow.- State classes, entities, and events are immutable. Use
freezed— it generates==,hashCode,copyWith,toString, and pattern-match-friendly unions. - Collection fields default to
const []/const {}— avoidnullfor "empty".
Equality
- Don't write `==` by hand. Either use
freezed, or — for pure value types that don't need unions — arecord. Equatableis legacy here. If you see it, it predates freezed adoption.
Null safety
- Prefer a non-nullable field with a sensible default over a nullable one.
requiredon all non-defaulted named parameters.- The bang operator
!is a smell. Useswitchwith a null pattern, orif (x case final value?), orx ?? fallback. One!per small function is okay; two is a code review comment. lateis only for lazy init where non-null is guaranteed by construction (e.g.,late final controller = TextEditingController();).
Sealed classes & pattern matching
switchon sealed types is exhaustive — nodefault:needed. Add one only when you want a catch-all.- Use destructuring patterns (
:final value) to avoid intermediate variables. - Records for ephemeral tuples:
({String id, int count}). Don't let them leak across layers — prefer a named type.
Functions and constructors
- Prefer named parameters once you have more than two.
- Factories for validation-heavy construction:
factory OrderId.parse(String raw). - Extension methods for per-type helpers (mappers, formatters). Put them in a file next to the type.
Async
Future<T>orStream<T>. NoCompleterunless bridging from a callback API.unawaited(foo())when you deliberately fire-and-forget. Analysis flags barefoo();.- Guard
BuildContextacrossawait:
``dart await repo.submit(...); if (!context.mounted) return; context.go(const NextRoute().location); ``
- Cancel subscriptions in
close()/dispose(). Close sinks. Analysis enforces it.
Error handling
- Never
catchwithout typing, at leaston DioException/on SomeException. - Inside a repository: catch, map to
Failure, returnLeft. - Outside a repository: don't catch — let the
Eitherflow. rethrowcancellation:if (e is DioException && e.type == DioExceptionType.cancel) return Left(const CancelledFailure());.
Scope functions — what replaces them
Dart doesn't have Kotlin's scope functions. The usual replacements:
| Kotlin | Dart | |
|---|---|---|
let { ... } on nullable | if (x case final v?) { ... } | |
apply { ... } | cascade .. | |
also { ... } | just use the variable | |
run { ... } | IIFE (() { ... })() (rare) | |
with(x) { ... } | extension methods |
Cascades are idiomatic:
Collections
List.of,Map.offor shallow copies..unmodifiablewhen you hand out references.Iterable.whereType<T>()over.where((x) => x is T).cast<T>().- Avoid
first/lastwithout a fallback — usefirstOrNull.
Records — when to reach for them
- Method returns multiple values that don't need a name:
(String, int)for a parse result. - Inline pattern bindings:
final (name, age) = parseLine(input);. - Don't use them across layer boundaries. Name your types there.
Enums
- Dart enums can carry data and methods. Use them for closed, small sets with associated constants:
``dart enum Flavor { dev(apiBaseUrl: 'https://dev.example.com'), prod(apiBaseUrl: 'https://api.example.com'); const Flavor({required this.apiBaseUrl}); final String apiBaseUrl; } ``
- For richer unions (payload per variant), use a
sealed class+freezed.
Don'ts
- No
print. Use the injectedILogger. - No
newkeyword (redundant). - No
varin production code.finalfor locals, explicit types on fields and public APIs. - No
dynamicunless you're reaching into JSON you haven't typed yet. Type it and move on. - No exceptions as control flow.
- No static state mutated at runtime.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/cc-mobile-flutter/skills/dart-style/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dimitriremoiville/cc-mobile/dart-style)