Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion skills/flutter-add-widget-preview/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Use the Flutter Widget Previewer to render widgets in real-time, isolated from t

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:io` or `dart:ffi`. Widgets with transitive dependencies on `dart:io` will throw exceptions upon invocation, and `dart:ffi` dependencies will fail to load. Use conditional imports to mock or bypass these in preview mode.
- **No Native APIs:** Do not use native plugins or APIs from `dart:io` or `dart:ffi`. Widgets with transitive dependencies on `dart:io` or `dart:ffi` will throw exceptions upon invocation. Use conditional imports to mock or bypass these in preview mode.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The updated wording suggests that any widget with a transitive dependency on dart:io or dart:ffi will throw an exception upon invocation. It is clearer to specify that the exception occurs when the APIs are invoked. Additionally, since the primary change (resolved in Flutter 3.41) is that these dependencies no longer prevent compilation, explicitly mentioning this improvement provides valuable context for developers who may have previously avoided these libraries.

Suggested change
- **No Native APIs:** Do not use native plugins or APIs from `dart:io` or `dart:ffi`. Widgets with transitive dependencies on `dart:io` or `dart:ffi` will throw exceptions upon invocation. Use conditional imports to mock or bypass these in preview mode.
- **No Native APIs:** Do not use native plugins or APIs from `dart:io` or `dart:ffi`. While transitive dependencies on these libraries no longer prevent compilation, invoking their APIs will throw exceptions in the previewer. Use conditional imports to mock or bypass these in preview mode.

- **Asset Paths:** Use package-based paths for assets loaded via `dart:ui` `fromAsset` APIs (e.g., `packages/my_package_name/assets/my_image.png` instead of `assets/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 `size` parameter in the `@Preview` annotation if your widget is unconstrained, as the previewer defaults to constraining them to approximately half the viewport.
Expand Down
Loading