Skip to content
Back to skills

Dart Polymorphic Callback Via Constructor Injection

ASecurity

Implements a polymorphic reaction mechanism in Dart by defining a single-method interface and injecting it via the constructor, allowing decoupled event handling.

  • 581 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 30, 2026
educationreact

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill dart-polymorphic-callback-via-constructor-injection --agent claude-code

Installs into .claude/skills of the current project.

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

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

Security grade badge for Dart Polymorphic Callback Via Constructor Injection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-dart-polymorphic-callback-via-constructor-injectio/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-dart-polymorphic-callback-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: "544fdb0a-05ba-4bcc-a50f-d1ce75b15a5f"
name: "Dart Polymorphic Callback via Constructor Injection"
description: "Implements a polymorphic reaction mechanism in Dart by defining a single-method interface and injecting it via the constructor, allowing decoupled event handling."
version: "0.1.0"
tags:
  - "dart"
  - "polymorphism"
  - "dependency-injection"
  - "interface"
  - "software-design"
triggers:
  - "implement polymorphic reaction in dart"
  - "dart dependency injection callback interface"
  - "pass callback via constructor dart"
  - "polymorphic purchase reaction dart"
---

# Dart Polymorphic Callback via Constructor Injection

Implements a polymorphic reaction mechanism in Dart by defining a single-method interface and injecting it via the constructor, allowing decoupled event handling.

## Prompt

# Role & Objective
You are a Dart software engineer. Your task is to implement a class that triggers a polymorphic reaction to a specific event (e.g., a successful purchase) using dependency injection.

# Operational Rules & Constraints
1. **Language**: Use Dart syntax.
2. **Interface Definition**: Define an abstract class (interface) containing a single method representing the reaction (e.g., `onSuccessfulPurchase`).
3. **Dependency Injection**: The main class (e.g., `Merch`) must accept the interface as a required parameter in its constructor.
4. **Polymorphism**: Provide at least two concrete implementations of the interface to demonstrate different reactions.
5. **Invocation**: The main class must call the interface method when the specific event occurs within its logic.

# Anti-Patterns
- Do not hardcode the reaction logic inside the main class.
- Do not use concrete classes for the dependency type in the main class constructor; use the abstract interface.

## Triggers

- implement polymorphic reaction in dart
- dart dependency injection callback interface
- pass callback via constructor dart
- polymorphic purchase reaction 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.