# Dart Logic Patterns

> Apply efficient algorithms, data structures, and Dart 3 pattern matching for clean business logic. Use when implementing search, sorting, debouncing, memoization, or exhaustive control flow in domain layers.

- **Type:** Skill
- **Install:** `agentstack add skill-dhruvanbhalara-skills-dart-logic-patterns`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [dhruvanbhalara](https://agentstack.voostack.com/s/dhruvanbhalara)
- **Installs:** 0
- **Category:** [Search](https://agentstack.voostack.com/c/search)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [dhruvanbhalara](https://github.com/dhruvanbhalara)
- **Source:** https://github.com/dhruvanbhalara/skills/tree/main/skills/dart/dart-logic-patterns
- **Website:** https://dhruvanbhalara.github.io/skills/

## Install

```sh
agentstack add skill-dhruvanbhalara-skills-dart-logic-patterns
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Algorithms & Logic

The efficiency of your business logic directly impacts battery life and responsiveness.

## Complexity Analysis
- **Big O Awareness**: Understand the cost of your operations. Avoid O(n²) or higher on the main thread for datasets larger than a few hundred items.
- **Data Structure Selection**:
  - `Map`: Fast key-based lookups.
  - `Set`: Fast unique item management.
  - `List`: Fast indexing and sequential access.
  - `LinkedHashSet/Map`: Preserves insertion order while providing fast lookups.

## Logic Patterns
- **Debouncing**: Delay execution until a user stops interacting (e.g., search-as-you-type).
- **Throttling**: Limit execution to at most once every interval (e.g., scrolling events).
- **Memoization**: Cache the results of expensive pure functions based on their arguments. Use `package:memoize` or custom implementations.
- **Pattern Matching (Dart 3+)**: Use switch expressions and exhaustive pattern matching for control flow instead of deeply nested if-else chains. This is a core part of clean Dart logic.

## Search & Sort
- **Binary Search**: Use for sorted lists to transform O(n) searches into O(log n).
- **Efficient Sorting**: Use Dart's built-in `list.sort()`, which uses highly optimized algorithms. Provide targeted `Comparable` implementations for custom objects.

## Business Logic Organization
- **Pure Functions**: Keep business logic in pure, testable functions outside of UI classes.
- **Fail Fast**: Use guard clauses to handle edge cases and invalid states early.
- **Validation Logic**: Keep complex validation in a separate domain layer, reusable across different screens.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [dhruvanbhalara](https://github.com/dhruvanbhalara)
- **Source:** [dhruvanbhalara/skills](https://github.com/dhruvanbhalara/skills)
- **License:** MIT
- **Homepage:** https://dhruvanbhalara.github.io/skills/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-dhruvanbhalara-skills-dart-logic-patterns
- Seller: https://agentstack.voostack.com/s/dhruvanbhalara
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
