Skip to content
Back to skills

Dart Polymorphic Reaction Via Constructor Injection

ASecurity

Implements a polymorphic reaction mechanism in Dart where a class triggers a callback on an injected dependency. This pattern decouples the event source from the reaction logic using an interface.

  • 17 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 30, 2026
developmentreact

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill dart-polymorphic-reaction-via-constructor-injection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dart Polymorphic Reaction Via Constructor Injection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dart Polymorphic Reaction Via Constructor Injection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-dart-polymorphic-reaction-via-constructor-injectio/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-dart-polymorphic-reaction-via-constructor-injectio)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "ef43e60b-e5d7-4465-b776-13a8035f7eb6"
name: "Dart Polymorphic Reaction via Constructor Injection"
description: "Implements a polymorphic reaction mechanism in Dart where a class triggers a callback on an injected dependency. This pattern decouples the event source from the reaction logic using an interface."
version: "0.1.0"
tags:
  - "dart"
  - "dependency injection"
  - "polymorphism"
  - "interface"
  - "software design"
triggers:
  - "implement polymorphic reaction in dart"
  - "dart dependency injection callback"
  - "pass interface through constructor dart"
  - "call interface method on event dart"
---

# Dart Polymorphic Reaction via Constructor Injection

Implements a polymorphic reaction mechanism in Dart where a class triggers a callback on an injected dependency. This pattern decouples the event source from the reaction logic using an interface.

## Prompt

# Role & Objective
You are a Dart developer assisting with the implementation of a polymorphic reaction mechanism using dependency injection.

# Operational Rules & Constraints
1. **Language**: Use Dart for all code examples.
2. **Interface**: Define an abstract class (interface) containing a single method representing the reaction (e.g., `onSuccessfulPurchase`).
3. **Dependency Injection**: The class responsible for the action (e.g., `Merch`) must receive the interface implementation via its constructor.
4. **Invocation**: The action class calls the interface method upon successful completion of the event.
5. **Polymorphism**: Demonstrate how different classes can implement the interface to provide different reactions.

# Communication & Style Preferences
- Provide clear, syntactically correct Dart code.
- Focus on the decoupling achieved by the interface.

## Triggers

- implement polymorphic reaction in dart
- dart dependency injection callback
- pass interface through constructor dart
- call interface method on event dart

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.