flutter-add-widget-preview
Use when configuring widget previews in Flutter development, testing visual component variations, or isolating widget UI states.
Skill by dhruvanbhalara
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/dhruvanbhalara-flutter-add-widget-preview
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, frontend, testing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 26, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/flutter-add-widget-preview
What's inside
- Skill name
flutter-add-widget-preview- Description
- Use when configuring widget previews in Flutter development, testing visual component variations, or isolating widget UI states.
- License
- MIT
- Metadata
- category: ui · languages: dart · platforms: flutter
- Instructions
- 163 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
## Contents
- [Preview Guidelines](#preview-guidelines)
- [Handling Limitations](#handling-limitations)
- [IDE and CLI Integration](#ide-and-cli-integration)
- [Custom Annotations](#custom-annotations)
- [Workflow: Adding a Widget Preview](#workflow-adding-a-widget-preview)
- [Examples](#examples)
## Preview Guidelines
Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
- **Target Elements**: Apply the `@Preview` annotation to:
- Top-level functions returning `Widget`
- Static methods within a class returning `Widget`
- Public widget constructors/factories with no required arguments
- **Import**: Always import `package:flutter/widget_previews.dart`.
- **Multiple Configurations**: Apply multiple `@Preview` annotations to a single target for multiple preview instances (e.g., light/dark mode).
- **Naming**: Use `name` and `group` parameters for organized preview panels.
- **Sizing**: Apply explicit constraints using the `size` parameter if the widget is unconstrained (the previewer defaults to approximately half the viewport).
## Handling Limitations
The Widget Previewer runs in a **web environment**. Adhere to these constraints:
| Limitation | Impact | Workaround |
|---|---|---|
| No `dart:io` | File system, sockets unavailable | Use conditional imports to mock |
| No `dart:ffi` | Native code won't execute | Stub native calls in preview mode |
| Asset paths | `dart:ui` `fromAsset` requires package paths | Use `packages/my_package/assets/...` |
| Callbacks | Must be public and constant | No closures in annotation params |
| Unconstrained widgets | May render incorrectly | Set `size` parameter in `@Preview` |
## IDE and CLI Integration
### IDE (Android Studio, IntelliJ, VS Code with Flutter 3.38+)
1. Launch the IDE. The Widget Previewer starts automatically.
2. Open the **"Flutter Widget Preview"** tab in the sidebar.
3. Toggle **"Filter previews by selected file"** at the bottom left to view previews outside the active file.
### Command Line
```bash
flutter widget-preview start
```
Opens a Chrome environment with live previews.
### Feedback Loop
1. Modify the widget code or preview configuration.
2. Observe the automatic update in the Widget Previewer.
3. If global state was modified → click global hot restart (bottom right).
4. If only local widget state needs resetting → click individual hot restart on the preview card.
5. Review errors in the IDE/CLI console → fix → repeat.
## Custom Annotations
### Extending Preview
Create reusable preview configurations by extending the `Preview` class:
```dart
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
final class ThemedPreview extends Preview {
const ThemedPreview({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()
..name = 'Themed - ${originalPreview.name}'
..theme = _themeBuilder;
return builder.toPreview();
}
}
@ThemedPreview(name: 'Primary Button')
Widget primaryButton() => const ElevatedButton(onPressed: null, child: Text('Click'));
```
### MultiPreview for Brightness Variants
```dart
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() {
return super.transform().map((preview) {
final builder = preview.toBuilder()
..group = 'Brightness'
..name = '$name - ${preview.brightness!.name}';
return builder.toPreview();
}).toList();
}
}
@MultiBrightnessPreview(name: 'User Card')
Widget userCard() => const Card(
child: Padding(padding: EdgeInsets.all(16), child: Text('John Doe')),
);
```
## Workflow: Adding a Widget Preview
### Task Progress
- [ ] **Step 1**: Import `package:flutter/widget_previews.dart`.
- [ ] **Step 2**: Identify valid target (top-level function, static method, or no-arg constructor).From dhruvanbhalara/skills, MIT.
More from dhruvanbhalara/skills
- 0.611score
dart-fix-runtime-errors
dhruvanbhalara
Use when diagnosing runtime failures, type cast errors, null check violations, or unhandled asynchronous exceptions in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-build-cli-app
dhruvanbhalara
Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-logic-patterns
dhruvanbhalara
Use when organizing business logic, implementing algorithmic workflows, or applying Dart data structures and pattern matching.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-memory
dhruvanbhalara
Use when troubleshooting memory leaks, optimizing garbage collection overhead, or disposing streams and listeners in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-apply-architecture-best-practices
dhruvanbhalara
Use when structuring Flutter application layers across data, domain, and presentation using Clean Architecture and BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc
dhruvanbhalara
Use when implementing state management with sealed BLoC classes, registering dependency injection with injectable, or setting up GoRouter listeners.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc-forms
dhruvanbhalara
Use when managing complex form state, synchronous and asynchronous input validation, or form submission transitions in BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-config
dhruvanbhalara
Use when configuring build flavors, passing environment variables via dart-define-from-file, or setting up stage-specific credentials.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-debugging
dhruvanbhalara
Use when diagnosing Flutter layout issues, inspecting widget rebuilds, setting breakpoints, or tracking down UI rendering anomalies.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-devtools
dhruvanbhalara
Use when profiling CPU performance, tracking memory leaks, inspecting widget trees, or viewing network traffic in Flutter DevTools.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-dio
dhruvanbhalara
Use when configuring HTTP network clients with Dio, adding auth token interceptors, handling retry logic, or caching API responses.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-firebase
dhruvanbhalara
Use when integrating Firebase Authentication, Cloud Firestore, Cloud Messaging, Crashlytics, or Firebase Analytics in Flutter.
SkillBFreshness: B★ 30Claude Code +9
Signals
- Stars
- 30
- Forks
- 4
- Open issues
- 0
- Last commit (this folder)
- Aug 29, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/dhruvanbhalara/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from dhruvanbhalara
- 0.611score
dart-fix-runtime-errors
dhruvanbhalara
Use when diagnosing runtime failures, type cast errors, null check violations, or unhandled asynchronous exceptions in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-build-cli-app
dhruvanbhalara
Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-logic-patterns
dhruvanbhalara
Use when organizing business logic, implementing algorithmic workflows, or applying Dart data structures and pattern matching.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-memory
dhruvanbhalara
Use when troubleshooting memory leaks, optimizing garbage collection overhead, or disposing streams and listeners in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-apply-architecture-best-practices
dhruvanbhalara
Use when structuring Flutter application layers across data, domain, and presentation using Clean Architecture and BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc
dhruvanbhalara
Use when implementing state management with sealed BLoC classes, registering dependency injection with injectable, or setting up GoRouter listeners.
SkillBFreshness: B★ 30Claude Code +9
Cite this page
flutter-add-widget-preview skill. Agent Mart. https://agentmart.dev/skills/dhruvanbhalara-flutter-add-widget-preview (last updated 2026-10-24)