j4flmao/agent-skills/dart
Claude Code and agent skill by j4flmao/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use this skill when the user says 'Dart', 'Dart 3', 'null safety', 'records', 'patterns', 'sealed class', 'Future', 'Stream', 'async*', 'isolate', 'Isolate.run', 'dart:ffi', 'pub', 'build_runner', 'freezed', 'dart test'. Writes and reviews idiomatic Dart 3: sound null safety, records/patterns/sealed classes, async with Futures and Streams, isolates for CPU work, FFI, code generation and testing. Do NOT use for: Flutter widget and state-management architecture (use flutter-expertise / flutter-internals), backend frameworks in other languages.
Install
npx vskill@latest install j4flmao/agent-skills/dartSKILL.md
Dart
Purpose
Dart is the language under Flutter and also runs CLIs and servers. Dart 3 made null safety mandatory and added records, patterns and class modifiers, which change how idiomatic code is written. This skill covers those features, the single-threaded event-loop model and when to move work to isolates.
Agent Protocol
Trigger
"Dart", "Dart 3", "null safety", "records", "patterns", "sealed class", "Future", "Stream", "isolate", "Isolate.run", "dart:ffi", "pub", "build_runner", "freezed".
Input Context
- Dart SDK version (from
pubspec.yamlenvironment.sdk) and whether Flutter is involved - Platform (mobile, web via dart2js/dart2wasm, CLI/server AOT)
- Lints in use (
package:lints,flutter_lints,very_good_analysis)
Output Artifact
Dart code, pubspec.yaml/analysis_options.yaml changes, tests. No file unless requested.
Response Format
1. Execution Model
- One thread per isolate with an event loop (microtask queue first, then event queue).
Futures andStreams are scheduled callbacks on that loop — they do not run in parallel. - Isolates have separate heaps and communicate by message passing; use them for CPU-heavy work so the UI/event loop stays responsive.
- Compilation: JIT with hot reload during development; AOT native code for release (mobile,
dart compile exe); JavaScript (dart2js) or WebAssembly (dart2wasm) on the web.
2. Null Safety
- Types are non-nullable by default;
String?allows null. Flow analysis promotes after checks (if (x != null) x.length). Promotion does not apply to public fields that could change — copy to a local first. - Operators:
?.,??,??=,!(throws if null — use only where an invariant guarantees non-null). latedefers initialisation; reading before assignment throwsLateInitializationError— prefer constructor initialisation.
3. Dart 3 Features
- Class modifiers:
sealed,final,base,interface,mixin classcontrol extension/implementation outside the library. - Extension types (Dart 3.3) wrap a value with a zero-cost static interface (
extension type UserId(int value) {}). - Static metaprogramming (macros) was cancelled in 2025; keep using code generation (
build_runnerwithjson_serializable,freezed).
4. Async Patterns
- Always
awaitor deliberately handle a Future; enable theunawaited_futures/discarded_futureslints and useunawaited(...)(dart:async) when fire-and-forget is intended. - Run independent work concurrently with
Future.wait([...])or record syntaxfinal (a, b) = await (fa, fb).wait;. - Streams: single-subscription vs broadcast; cancel
StreamSubscriptions indispose;async*+yieldto produce streams. - Errors thrown in a Future without a handler surface as uncaught zone errors — handle them at the boundary.
5. Isolates
Isolate.runspawns, runs and returns one result — ideal for one-off CPU work (JSON decode of large payloads, image processing, crypto). In Flutter,compute()wraps the same idea.- Long-lived workers:
Isolate.spawn+SendPort/ReceivePort. Messages are copied (except transferable typed data and immutable objects in the same isolate group); closures sent toIsolate.runmust not capture unsendable objects (e.g. open sockets). - Isolates are not available on the web (use web workers via JS interop).
6. FFI and Interop
dart:fficalls C APIs:DynamicLibrary.open,lookupFunction,Pointer,Struct; generate bindings withpackage:ffigen. Native assets (build hooks) package native code with a package.- JS interop on the web:
dart:js_interopwith extension types (required for dart2wasm).
7. Tooling
dart format,dart analyze(withpackage:lints/recommended.yamlor stricter),dart fix --apply,dart test(package:test,package:mocktailfor mocks),dart pub outdated.dart compile exe bin/main.dartfor a self-contained native CLI.
8. Anti-Patterns
| Anti-pattern | Problem | Fix | |
|---|---|---|---|
Heavy synchronous work in async functions | blocks the event loop (UI jank) | Isolate.run | |
! to silence the analyzer | runtime null errors | restructure, local promotion | |
Forgotten await | lost errors, wrong order | lints + explicit unawaited | |
dynamic everywhere / unchecked jsonDecode casts | runtime type errors | typed models, generated fromJson | |
| Not cancelling stream subscriptions | leaks, callbacks after dispose | cancel in dispose |
9. Checklist
- [ ] SDK constraint
>=3.x; strict lints enabled - [ ] No unjustified
!orlate - [ ] Sealed hierarchies + exhaustive
switchfor state/results - [ ] CPU-heavy work moved to isolates; Futures awaited or explicitly unawaited
- [ ]
dart analyzeclean anddart testpassing in CI
References
references/dart-fundamentals.md— null safety, mixins, streamsreferences/dart-advanced.md— isolates, FFI, code generationreferences/bloc-generics.md— generics in BLoC-style state managementreferences/dart-testing.md— unit and widget tests
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 repositoryCheckingskills/languages/dart/SKILL.md
Popularity
- Repository stars
- 27
- Repository forks
- 1
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. 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/j4flmao/agent-skills/dart)