ComponentDefinition<T extends ThemeableState> class
Definition of a component for the workbench registry.
This class encapsulates all information needed to:
- Create a new state instance
- Build the preview widget
- Build the controls panel
- Categorize and search for components
Using this registry pattern eliminates the need for 55+ if-statements in main.dart, reducing it from 2,600 lines to ~400 lines.
Constructors
-
ComponentDefinition({required ComponentType type, required String name, required ComponentCategory category, required String description, required List<
String> tags, required T stateBuilder(), required Widget controlsBuilder(T state, VoidCallback onChanged, bool isDarkMode), required Widget previewBuilder(T state, AnimationController? controller), bool requiresAnimationController = true}) -
const
Properties
- category → ComponentCategory
-
Category for grouping in the sidebar.
final
- controlsBuilder → Widget Function(T state, VoidCallback onChanged, bool isDarkMode)
-
Builder function for the controls panel.
Parameters:
final
- description → String
-
Description shown in search results and tooltips.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Human-readable name shown in the UI.
final
- previewBuilder → Widget Function(T state, AnimationController? controller)
-
Builder function for the preview widget.
Parameters:
final
- requiresAnimationController → bool
-
Whether this component requires an animation controller.
If true, the workbench will pass its shared animation controller
to the preview builder.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stateBuilder → T Function()
-
Factory function to create a new state instance.
final
-
Tags for filtering and searching.
Examples: 'interactive', 'voice-first', 'elderly-friendly'
final
- type → ComponentType
-
Unique identifier for this component.
final
Methods
-
buildControlsWidget(
ThemeableState state, VoidCallback onChanged, bool isDarkMode) → Widget - Build controls widget accepting ThemeableState base type. This method handles the generic type cast internally, eliminating the need for dynamic casts in the registry.
-
buildPreviewWidget(
ThemeableState state, AnimationController? controller) → Widget - Build preview widget accepting ThemeableState base type. This method handles the generic type cast internally, eliminating the need for dynamic casts in the registry.
-
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