dart-optimization

Installation
SKILL.md

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).
  • Private Named Parameters: Use Dart 3.12+ MyClass({this._privateField}) constructors to eliminate initializer list code boilerplate (see dart-modern-syntax).
Installs
165
GitHub Stars
20
First Seen
Mar 2, 2026
dart-optimization — dhruvanbhalara/skills