Skip to content

Update guidance around dart:ffi in widget previews#89

Merged
johnpryan merged 1 commit intomainfrom
widget-preview-ffi
Apr 24, 2026
Merged

Update guidance around dart:ffi in widget previews#89
johnpryan merged 1 commit intomainfrom
widget-preview-ffi

Conversation

@bkonyi
Copy link
Copy Markdown
Contributor

@bkonyi bkonyi commented Apr 24, 2026

dart:ffi imports in transitive dependencies used to prevent the widget previewer from compiling, but this was resolved in Flutter 3.41.

This change updates the guidance around dart:ffi to match that of dart:io, as dart:ffi APIs will now throw on invocation in the widget previewer.

`dart:ffi` imports in transitive dependencies used to prevent the widget previewer from compiling, but this was resolved in Flutter 3.41.

This change updates the guidance around `dart:ffi` to match that of `dart:io`, as `dart:ffi` APIs will now throw on invocation in the widget previewer.
@bkonyi bkonyi requested a review from johnpryan April 24, 2026 16:33
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation in SKILL.md regarding the use of native APIs in the Flutter Widget Previewer. The review suggests clarifying that while transitive dependencies on dart:io or dart:ffi no longer prevent compilation, invoking these APIs will still cause exceptions, and provides a more precise phrasing for the documentation.

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.

@johnpryan johnpryan merged commit ce729c1 into main Apr 24, 2026
7 checks passed
@johnpryan
Copy link
Copy Markdown
Collaborator

@bkonyi Since this skill is grounded in our docs, this indicates an issue we need to fix on the widget previewer docs page: flutter/website#13306

johnpryan added a commit to flutter/website that referenced this pull request Apr 24, 2026
See flutter/skills#89 for details

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants