·
Last changedVersion:
This version passed the hardening gate. Hardening applied 5 targeted changes and preserved all other text. Classified findings before hardening: 1. Classified findings closed: 0. Classified findings remaining: 1. Unclassified scanner findings remaining: 0. Review findings closed: 9. Review findings remaining: 4.
1
1
Expand | File | Group | Subtype | Severity | Status |
|---|---|---|---|---|---|
LICENSE | Excessive Agency & Rogue Autonomy | — | Low | Open |
1 finding
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. Keep .widget_preview/ out of version control, for example by listing it in the project git ignore file.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+): The IDE previewer also builds and runs project code, so open only repositories the user trusts.
If using the Command Line: Before launching, confirm that the repository is trusted and get the user's confirmation, because the previewer builds and runs the project code and its dependencies.
flutter widget-preview start.Feedback Loop: Preview Iteration
Get started with chainctlchainctl skill install public/flutter/flutter-add-widget-preview:latest
Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.
skills.cgr.dev/public/github.com/flutter/skills/flutter-add-widget-preview:latest
BSD-3-Clause
HARDENING.md
LICENSE
SKILL.md