dart-optimization
Use when profiling CPU hot paths, optimizing memory allocations, or enforcing static typing performance in Dart.
Skill by dhruvanbhalara
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/dhruvanbhalara-dart-optimization
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 26, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/dart-optimization
What's inside
- Skill name
dart-optimization- Description
- Use when profiling CPU hot paths, optimizing memory allocations, or enforcing static typing performance in Dart.
- License
- MIT
- Metadata
- category: optimization · languages: dart · platforms: dart
- Instructions
- 43 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Optimization & Debugging
Performance in Dart goes beyond UI rendering; it's about efficient execution, smart resource utilization, and sound error handling.
## Dart Performance Patterns
- **Standardize Types**: Avoid `dynamic`. Use explicit types or `Object?`. Statically typed code allows the compiler to perform far better optimizations.
- **Efficient Collections**:
- Use `Set` for average O(1) containment checks.
- Use `List` for ordered indexing.
- Prefer `Iterable` methods (`map`, `where`) for readability, but use `for` loops in performance-critical hot paths.
- **Inlining**: Small getters and trivial functions are often inlined by the VM/AOT, but keeping them simple ensures this optimization happens.
## Compile-Time Optimizations
- **Final & Const**: Declare variables as `final` whenever possible. Use `const` constructors for widgets and data models to enable compile-time allocation and reduce runtime garbage collection pressure.
- **Ternary vs If-Else**: In Dart, they are generally equivalent, but prioritize readability. Use `switch` expressions (Dart 3+) for exhaustive and efficient pattern matching.
- **Extension Types**: Use Dart 3.3+ `extension type` zero-cost abstractions for type wrapping to eliminate runtime allocation overhead (see [dart-modern-syntax](../dart-modern-syntax/SKILL.md)).
- **Private Named Parameters**: Use Dart 3.12+ `MyClass({this._privateField})` constructors to eliminate initializer list code boilerplate (see [dart-modern-syntax](../dart-modern-syntax/SKILL.md)).
## Hot Paths & Loops
- **Minimize Work in Loops**: Extract calculations and object creations outside of loops.
- **Collection Literals**: Use literal syntax `[]` or `{}` instead of constructors like `List()` for brevity and minor performance gains.
## Type System & Soundness
Enforce Dart's sound type system to prevent runtime invalid states.
- **Method Overrides:** Maintain sound return types (covariant) and parameter types (contravariant). Never tighten a parameter type in a subclass unless explicitly marked with the `covariant` keyword.
- **Generics & Collections:** Add explicit type annotations to generic classes (e.g., `List<T>`). Never assign a `List<dynamic>` to a typed list.
- **Downcasting:** Avoid implicit downcasts from `dynamic`. Use explicit casts (e.g., `as List<Cat>`) when necessary, but ensure the underlying runtime type matches to prevent `TypeError` exceptions.
- **Strict Casts:** Enable `strict-casts: true` in `analysis_options.yaml` to force explicit casting and catch implicit downcast errors at compile time.
## Null Safety & Error Handling
Eliminate static errors related to null safety by correctly managing variable initialization and nullability.
- **Modifiers:** Apply `?` for nullable types, `!` for null assertions, and `required` for named parameters that cannot be null.
- **Late Initialization:** Use the `late` keyword for non-nullable variables guaranteed to be initialized before use.
- **Catching:** Catch `Exception` subtypes for recoverable failures.
- **Errors:** Never explicitly catch `Error` or its subtypes (e.g., `TypeError`, `ArgumentError`). Errors indicate programming bugs that must be fixed, not caught.
- **Rethrowing:** Use `rethrow` inside a `catch` block to propagate an exception while preserving its original stack trace.
## Profiling & Debugging
- **DevTools CPU Profiler**: Identify hot paths and "heavy" functions.
- **Benchmarking**: Use `package:benchmark_harness` for scientific performance measurement of non-UI logic.
- **Hot Reload vs Restart**: Use hot reload for UI changes. For state initialization or deep logic changes that cause runtime errors, use hot restart to clear the state tree.From dhruvanbhalara/skills, MIT.
More from dhruvanbhalara/skills
- 0.611score
dart-fix-runtime-errors
dhruvanbhalara
Use when diagnosing runtime failures, type cast errors, null check violations, or unhandled asynchronous exceptions in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-build-cli-app
dhruvanbhalara
Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-logic-patterns
dhruvanbhalara
Use when organizing business logic, implementing algorithmic workflows, or applying Dart data structures and pattern matching.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-memory
dhruvanbhalara
Use when troubleshooting memory leaks, optimizing garbage collection overhead, or disposing streams and listeners in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-add-widget-preview
dhruvanbhalara
Use when configuring widget previews in Flutter development, testing visual component variations, or isolating widget UI states.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-apply-architecture-best-practices
dhruvanbhalara
Use when structuring Flutter application layers across data, domain, and presentation using Clean Architecture and BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc
dhruvanbhalara
Use when implementing state management with sealed BLoC classes, registering dependency injection with injectable, or setting up GoRouter listeners.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc-forms
dhruvanbhalara
Use when managing complex form state, synchronous and asynchronous input validation, or form submission transitions in BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-config
dhruvanbhalara
Use when configuring build flavors, passing environment variables via dart-define-from-file, or setting up stage-specific credentials.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-debugging
dhruvanbhalara
Use when diagnosing Flutter layout issues, inspecting widget rebuilds, setting breakpoints, or tracking down UI rendering anomalies.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-devtools
dhruvanbhalara
Use when profiling CPU performance, tracking memory leaks, inspecting widget trees, or viewing network traffic in Flutter DevTools.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-dio
dhruvanbhalara
Use when configuring HTTP network clients with Dio, adding auth token interceptors, handling retry logic, or caching API responses.
SkillBFreshness: B★ 30Claude Code +9
Signals
- Stars
- 30
- Forks
- 4
- Open issues
- 0
- Last commit (this folder)
- Aug 29, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/dhruvanbhalara/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from dhruvanbhalara
- 0.611score
dart-fix-runtime-errors
dhruvanbhalara
Use when diagnosing runtime failures, type cast errors, null check violations, or unhandled asynchronous exceptions in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-build-cli-app
dhruvanbhalara
Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-logic-patterns
dhruvanbhalara
Use when organizing business logic, implementing algorithmic workflows, or applying Dart data structures and pattern matching.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-memory
dhruvanbhalara
Use when troubleshooting memory leaks, optimizing garbage collection overhead, or disposing streams and listeners in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-add-widget-preview
dhruvanbhalara
Use when configuring widget previews in Flutter development, testing visual component variations, or isolating widget UI states.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-apply-architecture-best-practices
dhruvanbhalara
Use when structuring Flutter application layers across data, domain, and presentation using Clean Architecture and BLoC.
SkillBFreshness: B★ 30Claude Code +9
Cite this page
dart-optimization skill. Agent Mart. https://agentmart.dev/skills/dhruvanbhalara-dart-optimization (last updated 2026-10-24)