flutter-add-widget-preview

Adds interactive Flutter widget previews using the @Preview annotation and Widget Previewer.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill flutter-add-widget-preview-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-add-widget-preview
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/flutter-add-widget-preview
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill flutter-add-widget-preview-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flutter developers often need to test UI components in isolation without launching the full application, but setting up preview environments and handling platform constraints can be error-prone and time-consuming. ## Core Features & Use Cases - Preview Annotation Guidance: Apply the @Preview annotation to top-level functions, static methods, or parameter-less constructors to render widgets in isolation. - Custom and Multi-Preview Configurations: Extend the Preview or MultiPreview classes to inject themes, brightness variants, and runtime transformations across multiple widgets. - Limitation Handling: Work around web-environment constraints such as dart:io restrictions, asset path requirements, and public callback rules. - Use Case: When building a new design system component, annotate it with @Preview, launch the Widget Previewer via IDE or flutter widget-preview start, and iterate with hot restart until the component renders correctly in both light and dark modes. ## Quick Start Add an interactive preview to my Flutter widget using the @Preview annotation from package:flutter/widget_previews.dart.

Frequently Asked Questions about flutter-add-widget-preview

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a widget preview in Flutter?

Import package:flutter/widget_previews.dart and apply the @Preview annotation to a top-level function, static method, or public constructor with no required arguments that returns a Widget. Then launch the Widget Previewer from your IDE or run flutter widget-preview start.

How do I preview a Flutter widget in both light and dark mode?

Extend the MultiPreview class and return a list of Preview instances with Brightness.light and Brightness.dark. Apply your custom annotation to the widget to generate both variants automatically.

Can Flutter Widget Previewer use dart:io or native plugins?

No, the Widget Previewer runs in a web environment, so widgets with transitive dependencies on dart:io or dart:ffi will throw exceptions. Use conditional imports to mock or bypass native APIs in preview mode.

Why does my Flutter widget preview fail to load assets?

Assets loaded via dart:ui fromAsset APIs must use package-based paths like packages/my_package_name/assets/image.png instead of relative paths. The previewer's web environment cannot resolve plain asset paths.

How do I run Flutter Widget Previewer from the command line?

Navigate to your Flutter project's root directory and run flutter widget-preview start. A Chrome environment opens automatically showing all annotated previews, with hot restart buttons for refreshing state.