/dart-flutter:flutter-add-widget-previewfrom Dart and Flutter
Adds interactive widget previews to Flutter projects using the @Preview annotation system. Use when creating new UI components or updating screens for consistent design and interactive testing.
Ships in Dart and Flutter. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
@Preview annotation to top-level functions, static methods within a class, or public widget constructors/factories that have no required arguments and return a Widget or WidgetBuilder.package:flutter/widget_previews.dart to access the preview annotations.Preview class to create custom annotations that inject common properties (e.g., custom themes, wrappers, sizes) across multiple widgets.@Preview annotations to a single target to generate multiple preview instances. Alternatively, extend MultiPreview to encapsulate common multi-preview configurations.transform() method in custom Preview or MultiPreview classes to modify preview configurations dynamically at runtime (e.g., building names dynamically based on parameters, which is impossible in a const constructor).The @Preview annotation supports the following parameters for tailoring preview environments:
name: A descriptive name for the preview instance.group: A name used to group related previews together in the previewer.size: Artificial constraints using a Size object.textScaleFactor: Custom font scale factor.wrapper: A function that wraps the previewed widget in a specific widget tree (e.g., to inject state or inherited widgets).theme: A function returning a PreviewThemeData subclass instance to provide custom theming with support for sequential theme layering.brightness: The initial theme Brightness (Brightness.light or Brightness.dark).localizations: A function applying a localization configuration.Adhere to the following constraints when authoring previewable widgets, as the Widget Previewer runs in a web environment:
dart:io or dart:ffi. Widgets with transitive dependencies on dart:io or dart:ffi will throw exceptions upon invocation. Use conditional imports or wrappers to mock or bypass these in preview mode.dart:ui fromAsset APIs (e.g., packages/my_package_name/assets/my_image.png instead of assets/my_image.png).size parameter in the @Preview annotation if your widget is unconstrained, as unconstrained widgets default to roughly half the viewport..widget_preview/ folder in the project root.Copy and track this checklist when implementing a new widget preview:
package:flutter/widget_previews.dart.@Preview annotation to the target.name, group, size, textScaleFactor, wrapper, theme, brightness, localizations) as needed.Preview or MultiPreview.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.47+):
If using the Command Line:
flutter widget-preview start.Feedback Loop: Preview Iteration
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
@Preview(name: 'Submit Button', group: 'Form Controls')
Widget submitButtonPreview() => const ElevatedButton(
onPressed: null,
child: Text('Submit'),
);
import 'package:flutter/widget_previews.dart';
import 'package:flutter/material.dart';
final class ThemedPreview extends Preview {
const ThemedPreview({
super.name,
super.group,
super.brightness,
});
PreviewThemeData _themeBuilder() =>
CustomThemeData(brightness: brightness);
@override
Preview transform() {
final originalPreview = super.transform();
final themeVariant = switch (brightness) {
null => 'Responsive',
final b => b.name,
};
final builder = originalPreview.toBuilder();
final baseName = originalPreview.name ?? 'Preview';
builder
..name = '$baseName [$themeVariant]'
..theme = _themeBuilder;
return builder.build();
}
}
final class CustomThemeData extends PreviewThemeData {
const CustomThemeData({this.brightness});
final Brightness? brightness;
@override
Widget apply(BuildContext context, Widget child) {
return Theme(
data: ThemeData.from(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.teal,
brightness: brightness ??
MediaQuery.maybePlatformBrightnessOf(context) ??
Brightness.light,
),
),
child: child,
);
}
}
@ThemedPreview(name: 'Themed Action Button', brightness: Brightness.dark)
Widget themedButtonPreview() => const ElevatedButton(
onPressed: null,
child: Text('Action'),
);
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'),
),
);
What SKILL.md sets; muted values are Claude Code's defaults
25 skills in this plugin
/dart-add-unit-testWrite and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free./dart-build-cli-appArchitectural patterns, entrypoint structure, exit codes, stream routing, and subprocess spawning for Dart command-line interface (CLI) applications. Use when building CLI tools, console utilities, scripts, argument parsing with `package:args` (ArgParser or CommandRunner), handling exit codes, configuring executables in pubspec.yaml, spawning Dart subprocesses, or compiling native CLI binaries. Don't use for Flutter UI widgets, web applications, or standalone HTTP backend servers./dart-collect-coverageCollect coverage using the coverage packge and create an LCOV report/dart-fix-runtime-errorsUses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload./dart-generate-test-mocksDefine and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases./dart-migrate-to-checks-packageReplace the usage of `expect` and similar functions from `package:matcher`
to `package:checks` equivalents.npx claudepluginhub flutter/agent-plugins --plugin dart-flutterOther plugins' skills for the same job