-
Notifications
You must be signed in to change notification settings - Fork 28.8k
Add WidgetPreview and @Preview() annotation #159219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…review() annotation This is the initial work for the upcoming Widget Preview functionality. The WidgetPreview widget allows for users to specify overrides and details to apply to its child Widget. Initially, this includes: - Setting arbitrary width and height constraints to mimic changes in device resolution - Custom text scaling factors The previewed widget is currently wrapped in a Material Card which includes controls for zooming and panning within the zoomed in view. The WidgetPreviewerWindowConstraints widget propagates the constraints for the preview environment to each WidgetPreview widget to be used by the WidgetPreviewWrapper widget, a SingleChildRenderObjectWidget, to force constraints onto unconstrained children of WidgetPreview.
Is there a design doc for this new feature? I wonder if the framework should contain this source code, or if this is something that is intended for Devtools / Devtools extentions? |
There's currently not a publicly shared design doc, but I think I'm going to pull one together to better communicate how this feature is going to be architected. This particular code should live in the framework since it's meant to be included in a developer's codebase. The other components of this feature will live in the For example, this is an early prototype showing how a widget (in this case, the root of the Flutter Gallery application) can be previewed within VSCode by applying the |
A design doc can be found here: #159342 |
@bkonyi and I talked on Friday and we had the idea that what lives in the framework would ideally be fairly minimal. Maybe just the annotation and a WidgetPreview data class. |
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
Done, PTAL when you have a chance! |
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a8ef5e9
to
f5cf3bf
Compare
autosubmit label was removed for flutter/flutter/159219, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label. |
autosubmit label was removed for flutter/flutter/159219, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label. |
This is the initial work for the upcoming Widget Preview functionality.
The
WidgetPreview
class allows for users to specify overrides and details to apply to its childWidget
. Initially, this includes:The
Preview
class is an annotation used to identify top-level, public functions as widget previews