ComponentRegistry class

Central registry for all components in the workbench.

Purpose

This registry eliminates the need for 55+ if-statements in main.dart by providing a declarative, data-driven approach to component management.

Adding a New Component

  1. Create your component files:

    • lib/components/neumorphic/[category]/neumorphic_[name].dart
    • lib/playground/state/[name]_state.dart
    • lib/playground/controls/[name]_controls.dart
    • lib/playground/previews/[name]_preview.dart
  2. Ensure your state class implements ThemeableState

  3. Add imports above and an entry to the _components map below

  4. Done! No need to modify main.dart

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

allTags → Set<String>
Get all unique tags across all components.
no setter
components → Map<ComponentType, ComponentDefinition<ThemeableState>>
Get all registered components.
no setter
count → int
Get total number of registered components.
no setter
countByCategory → Map<ComponentCategory, int>
Get component count by category.
no setter

Static Methods

buildControls(ComponentType type, ThemeableState state, VoidCallback onChanged, bool isDarkMode) → Widget?
Build a controls widget for a component, handling type casting internally. Returns null if the component type is not registered.
buildPreview(ComponentType type, ThemeableState state, AnimationController? controller) → Widget?
Build a preview widget for a component, handling type casting internally. Returns null if the component type is not registered.
byCategory(ComponentCategory category) → List<ComponentDefinition<ThemeableState>>
Get all components in a category.
byTag(String tag) → List<ComponentDefinition<ThemeableState>>
Get all components with a specific tag.
createAllStates() → Map<ComponentType, ThemeableState>
Create new state instances for all registered components. Phase 1.4.10.2: Use stateBuilder from registry instead of manual initialization.
get(ComponentType type) → ComponentDefinition<ThemeableState>?
Get a component definition by type.
isRegistered(ComponentType type) → bool
Check if a component type is registered.
Search components by name, description, or tag.