flutter-add-widget-preview
Skill4 starsChanged 4 months agoMITView on GitHub
Adds interactive widget previews to the project using the previews.dart system. Use when creating new UI components or updating existing screens to ensure consistent design and interactive testing.
4 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- SamuelAlev/control-centerword for word, first seen Nov 8, 2026
- zhouycheng/skillsword for word, first seen Oct 13, 2026
- flutter/skillsedited, first seen Oct 8, 2026
- deretame/Breezeedited, first seen Oct 8, 2026
Other versions4 projects use a version of this.
Word for word · 2
- SamuelAlev/control-center★ 8100% same
- zhouycheng/skills★ 1100% same
Edited · 2
- flutter/skills★ 3.2k67% same
- deretame/Breeze★ 3k100% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- engine/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- engine/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- brandkitSkill
- code-reviewSkill
- dart-add-unit-testSkill
- dart-build-cli-appSkill
- dart-collect-coverageSkill
- dart-fix-runtime-errorsSkill
- dart-generate-test-mocksSkill
- dart-migrate-to-checks-packageSkill
- dart-resolve-package-conflictsSkill
- dart-run-static-analysisSkill
- dart-setup-ffi-assetsSkill
- dart-use-ffigenSkill
- dart-use-pattern-matchingSkill
- dart-use-primary-constructorsSkill
- design-taste-frontendSkill
- flutter-add-integration-testSkill
- flutter-add-widget-testSkill
- flutter-apply-architecture-best-practicesSkill
- flutter-build-responsive-layoutSkill
- flutter-fix-layout-issuesSkill
- flutter-implement-json-serializationSkill
- flutter-setup-declarative-routingSkill
- flutter-setup-localizationSkill
- flutter-use-http-packageSkill
- frontend-code-reviewSkill
- full-output-enforcementSkill
- github-releaseSkill
- grill-with-docsSkill
- high-end-visual-designSkill
- imagegen-frontend-webSkill
- image-to-codeSkill
- improve-codebase-architectureSkill
- industrial-brutalist-uiSkill
- minimalist-uiSkill
- redesign-existing-projectsSkill
- source-command-frontend-code-review-skillSkill
- source-command-impeccable-skillSkill
- stitch-design-tasteSkill
- tddSkill
- to-prdSkill
- frontend-code-reviewSkill
- impeccableSkill
- dart-add-unit-testSkill
- dart-build-cli-appSkill
- dart-collect-coverageSkill
- dart-fix-runtime-errorsSkill
- dart-generate-test-mocksSkill
- dart-migrate-to-checks-packageSkill
- dart-resolve-package-conflictsSkill
- dart-run-static-analysisSkill
- dart-setup-ffi-assetsSkill
- dart-use-ffigenSkill
- dart-use-pattern-matchingSkill
- dart-use-primary-constructorsSkill
- flutter-add-integration-testSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
- Very specific: line 21
Imports: Always import package:flutter/widget_previews.dart to access the preview annotations.
- Very specific: line 30
No Native APIs: Do not use native plugins or APIs from dart:io or dart:ffi.
- Very specific: line 31
Asset Paths: Use package-based paths for assets loaded via dart:ui fromAsset APIs (e.g., packages/my_package_name/assets/my_image.png …
- Distinctive: line 32
Public Callbacks: Ensure all callback arguments provided to preview annotations are public and constant to satisfy code generation …
- Distinctive: line 47
Follow the appropriate conditional workflow to launch and interact with the Widget Previewer:
- Distinctive: line 62
If global state (e.g., static initializers) was modified: Click the global hot restart button at the bottom right.
- Distinctive: line 63
If only the local widget state needs resetting: Click the individual hot restart button on the specific preview card.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Previewing Flutter Widgets
Contents
- Preview Guidelines
- Handling Limitations
- Workflows
- Examples
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).
Handling Limitations
Adhere to the following constraints when authoring previewable widgets, as the Widget Previewer runs in a web environment:
- No Native APIs: Do not use native plugins or APIs from
dart:ioordart:ffi. Widgets with transitive dependencies ondart:ioordart:ffiwill throw exceptions upon invocation. Use conditional imports to mock or bypass these in preview mode. - Asset Paths: Use package-based paths for assets loaded via
dart:uifromAssetAPIs (e.g.,packages/my_package_name/assets/my_image.pnginstead ofassets/my_image.png). - Public Callbacks: Ensure all callback arguments provided to preview annotations are public and constant to satisfy code generation requirements.
- Constraints: Apply explicit constraints using the
sizeparameter in the@Previewannotation if your widget is unconstrained, as the previewer defaults to constraining them to approximately half the viewport.
Workflows
Creating a Widget Preview
Copy and track this checklist when implementing a new widget preview:
- Import
package:flutter/widget_previews.dart. - Identify a valid target (top-level function, static method, or parameter-less public constructor).
- Apply the
@Previewannotation to the target. - Configure preview parameters (
name,group,size,theme,brightness, etc.) as needed. - If applying the same configuration to multiple widgets, extract the configuration into a custom class extending
Preview.
Interacting with Previews
Follow the appropriate conditional workflow to launch and interact with the Widget Previewer:
If using a supported IDE (Android Studio, IntelliJ, VS Code with Flutter 3.38+):
- Launch the IDE. The Widget Previewer starts automatically.
- Open the "Flutter Widget Preview" tab in the sidebar.
- Toggle "Filter previews by selected file" at the bottom left if you want to view previews outside the currently active file.
If using the Command Line:
- Navigate to the Flutter project's root directory.
- Run
flutter widget-preview start. - View the automatically opened Chrome environment.
Feedback Loop: Preview Iteration
- Modify the widget code or preview configuration.
- Observe the automatic update in the Widget Previewer.
- If global state (e.g., static initializers) was modified: Click the global hot restart button at the bottom right.
- If only the local widget state needs resetting: Click the individual hot restart button on the specific preview card.
- Review errors in the IDE/CLI console -> fix -> repeat.
Examples
Basic Preview
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
@Preview(name: 'My Sample Text', group: 'Typography')
Widget mySampleText() {
return const Text('Hello, World!');
}Custom Preview with Runtime Transformation
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
final class TransformativePreview extends Preview {
const TransformativePreview({
super.name,
super.group,
});
PreviewThemeData _themeBuilder() {
return PreviewThemeData(
materialLight: ThemeData.light(),
materialDark: ThemeData.dark(),
);
}
@override
Preview transform() {
final originalPreview = super.transform();
final builder = originalPreview.toBuilder();
builder
..name = 'Transformed - ${originalPreview.name}'
..theme = _themeBuilder;
return builder.toPreview();
}
}
@TransformativePreview(name: 'Custom Themed Button')
Widget myButton() => const ElevatedButton(onPressed: null, child: Text('Click'));MultiPreview Implementation
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
/// Creates light and dark mode previews automatically.
final class MultiBrightnessPreview extends MultiPreview {
const MultiBrightnessPreview({required this.name});
final String name;
@override
List<Preview> get previews => const [
Preview(brightness: Brightness.light),
Preview(brightness: Brightness.dark),
];
@override
List<Preview> transform() {
final previews = super.transform();
return previews.map((preview) {
final builder = preview.toBuilder()
..group = 'Brightness'
..name = '$name - ${preview.brightness!.name}';
return builder.toPreview();
}).toList();
}
}
@MultiBrightnessPreview(name: 'Primary Card')
Widget cardPreview() => const Card(child: Padding(padding: EdgeInsets.all(8.0), child: Text('Content')));Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

