flutter-add-widget-preview
Installation
SKILL.md
Previewing Flutter Widgets
Contents
Preview Guidelines
Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
- Target Elements: Apply the
@Previewannotation to top-level functions, static methods within a class, or public widget constructors/factories that have no required arguments and return aWidgetorWidgetBuilder. - Imports: Always import
package:flutter/widget_previews.dartto access the preview annotations. - Custom Annotations: Extend the
Previewclass to create custom annotations that inject common properties (e.g., themes, wrappers) across multiple widgets. - Multiple Configurations: Apply multiple
@Previewannotations to a single target to generate multiple preview instances. Alternatively, extendMultiPreviewto encapsulate common multi-preview configurations. - Runtime Transformations: Override the
transform()method in customPrevieworMultiPreviewclasses to modify preview configurations dynamically at runtime (e.g., generating names based on dynamic values, which is impossible in aconstcontext).