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
-
Create your component files:
lib/components/neumorphic/[category]/neumorphic_[name].dartlib/playground/state/[name]_state.dartlib/playground/controls/[name]_controls.dartlib/playground/previews/[name]_preview.dart
-
Ensure your state class implements
ThemeableState -
Add imports above and an entry to the
_componentsmap below -
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(
String query) → List< ComponentDefinition< ThemeableState> > - Search components by name, description, or tag.