dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains…
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.
$ npx -y skills add flutter/agent-plugins --skill flutter-add-widget-preview --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/flutter-add-widget-previewContext preview
The summary Claude sees to decide when to auto-load this skill.
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.
name: flutter-add-widget-preview description: 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. metadata: model: models/gemini-3.1-pro-preview last_modified: Tue, 21 Apr 2026 20:05:23 GMT
Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
Adhere to the following constraints when authoring previewable widgets, as the Widget Previewer runs in a web environment:
Copy and track this checklist when implementing a new widget preview:
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+):** 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 if you want to view previews outside the currently active file.
**If using the Command Line:** 1. Navigate to the Flutter project's root directory. 2. Run `flutter widget-preview start`. 3. View the automatically opened Chrome environment.
**Feedback Loop: Preview Iteration** 1. Modify the widget code or preview configuration. 2. Observe the automatic update in the Widget Previewer. 3. If global state (e.g., static initializers) was modified: Click the global hot restart button at the bottom right. 4. If only the local widget state needs resetting: Click the individual hot restart button on the specific preview card. 5. Review errors in the IDE/CLI console -> fix -> repeat.
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!');
}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'));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 = '$nameAgent plugins for Flutter, maintained by the Flutter team. A collection of plugins designed to extend AI agent capabilities for Flutter development.
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains…
Architectural patterns, entrypoint structure, exit codes, stream routing, and subprocess spawning for Dart command-line interface (CLI) applications. Use when…
Collect coverage using the coverage packge and create an LCOV report
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex…
Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents.