-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[ Widget Preview ] Allow for custom Preview annotations, add support for runtime transformations
#175535
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
…t for runtime transformations This change updates `Preview` to be a `base` class instead of `final`, allowing for developers to extend `Preview` and create their own custom preview annotations. To reduce friction associated with working with `const` constructors, two new methods have been added: `MultiPreview.transform()` and `Preview.transform()`. These methods are invoked at runtime by the preview environment, allowing for developers to create or modify `Preview` instances with non-constant values. This also relaxes restrictions around `Preview`'s callback parameters (e.g., `wrapper`), which do not need to be static or public when provided to a `Preview` in the context of a `*.transform()` method. This makes it possible to create custom preview classes that completely encapsulate their callbacks, removing the need for separate public, static function declarations. To make transforming `Preview`s simpler, a `PreviewBuilder` utility class has also been added. Fixes #175534
elliette
left a comment
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.
A few suggestions but otherwise LGTM!
packages/flutter_tools/lib/src/widget_preview/preview_code_generator.dart
Outdated
Show resolved
Hide resolved
...flutter_tools/test/commands.shard/hermetic/widget_preview/utils/preview_details_matcher.dart
Outdated
Show resolved
Hide resolved
|
autosubmit label was removed for flutter/flutter/175535, because - The status or check suite Linux build_tests_1_5 has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/175535, because - The status or check suite Linux build_tests_3_5 has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/175535, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/175535, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…add support for runtime transformations (flutter/flutter#175535)
…10067) Manual roll requested by [email protected] flutter/flutter@9ff2767...4a04204 2025-09-23 [email protected] Simplify asserts in `FlutterMutatorTest` (flutter/flutter#175730) 2025-09-23 [email protected] Improve code quality in `AccessibilityBridgeTest.java` (flutter/flutter#175718) 2025-09-23 [email protected] Fix linter issues in `VsyncWaiterTest` Capital L for long values (flutter/flutter#175780) 2025-09-23 [email protected] Fix wrong order of asserts arguments (flutter/flutter#175726) 2025-09-23 [email protected] Simplify test asserts and use lambdas (flutter/flutter#175727) 2025-09-23 [email protected] Remove unused imports, fix assertion order, add non null annotations to `ImageReaderPlatformViewRenderTargetTest.java` (flutter/flutter#175723) 2025-09-23 [email protected] Remove unnecessary `String.valueOf` in `KeyboardManager.java` (flutter/flutter#175502) 2025-09-23 [email protected] Fix outdated link of `intl` package to point to the correct new location (flutter/flutter#174498) 2025-09-23 [email protected] Roll Packages from 45c9a84 to 3413b65 (4 revisions) (flutter/flutter#175854) 2025-09-23 [email protected] Fix typo in tests `README` (flutter/flutter#175788) 2025-09-23 [email protected] Update maximum known Gradle version to 9.1.0 (flutter/flutter#175543) 2025-09-23 [email protected] Roll Dart SDK from 9e943fe076c8 to 14b4ced3022a (5 revisions) (flutter/flutter#175843) 2025-09-23 [email protected] Document how to hide counter in TextField.maxLength (flutter/flutter#175797) 2025-09-23 [email protected] [a11y-app] Fix Autocomplete semantics label (flutter/flutter#175409) 2025-09-23 [email protected] Roll Fuchsia Linux SDK from CcCe3HpQtBYhTZscb... to naeytagBIBEpKgZNZ... (flutter/flutter#175824) 2025-09-23 [email protected] Roll Skia from a38a531dec1d to cabeab8cb22c (16 revisions) (flutter/flutter#175822) 2025-09-23 [email protected] Load fonts in the order addFont is called (flutter/flutter#174253) 2025-09-22 [email protected] Roll pub packages (flutter/flutter#175545) 2025-09-22 [email protected] Remove `name` field form `SupportedPlatform` enum (flutter/flutter#175611) 2025-09-22 [email protected] [web] Cleanup opportunities post renderer unification (flutter/flutter#174659) 2025-09-22 [email protected] Update `KeyChannelResponder.java` to use method reference (flutter/flutter#175510) 2025-09-22 [email protected] Update docs/engine/contributing/Compiling-the-engine.md with macOS build steps (flutter/flutter#175716) 2025-09-22 [email protected] [ Widget Preview ] Allow for custom `Preview` annotations, add support for runtime transformations (flutter/flutter#175535) 2025-09-22 [email protected] Remove unnecessary public modifier in `KeyboardManager.java` (flutter/flutter#175500) 2025-09-22 [email protected] bump robolectric and java to 21 (flutter/flutter#175550) 2025-09-22 [email protected] Fix: Update docs tool tag to sample in ImageProvider (flutter/flutter#175256) 2025-09-22 [email protected] Roll Packages from 3d5c419 to 45c9a84 (flutter/flutter#175794) 2025-09-21 [email protected] Correctly implement PlatformViews' cursors on Web (flutter/flutter#174300) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…t for runtime transformations (flutter#175535) This change updates `Preview` to be a `base` class instead of `final`, allowing for developers to extend `Preview` and create their own custom preview annotations. To reduce friction associated with working with `const` constructors, two new methods have been added: `MultiPreview.transform()` and `Preview.transform()`. These methods are invoked at runtime by the preview environment, allowing for developers to create or modify `Preview` instances with non-constant values. This also relaxes restrictions around `Preview`'s callback parameters (e.g., `wrapper`), which do not need to be static or public when provided to a `Preview` in the context of a `*.transform()` method. This makes it possible to create custom preview classes that completely encapsulate their callbacks, removing the need for separate public, static function declarations. To make transforming `Preview`s simpler, a `PreviewBuilder` utility class has also been added. Fixes flutter#175534
…add support for runtime transformations (flutter/flutter#175535)
…t for runtime transformations (flutter#175535) This change updates `Preview` to be a `base` class instead of `final`, allowing for developers to extend `Preview` and create their own custom preview annotations. To reduce friction associated with working with `const` constructors, two new methods have been added: `MultiPreview.transform()` and `Preview.transform()`. These methods are invoked at runtime by the preview environment, allowing for developers to create or modify `Preview` instances with non-constant values. This also relaxes restrictions around `Preview`'s callback parameters (e.g., `wrapper`), which do not need to be static or public when provided to a `Preview` in the context of a `*.transform()` method. This makes it possible to create custom preview classes that completely encapsulate their callbacks, removing the need for separate public, static function declarations. To make transforming `Preview`s simpler, a `PreviewBuilder` utility class has also been added. Fixes flutter#175534
…t for runtime transformations (flutter#175535) This change updates `Preview` to be a `base` class instead of `final`, allowing for developers to extend `Preview` and create their own custom preview annotations. To reduce friction associated with working with `const` constructors, two new methods have been added: `MultiPreview.transform()` and `Preview.transform()`. These methods are invoked at runtime by the preview environment, allowing for developers to create or modify `Preview` instances with non-constant values. This also relaxes restrictions around `Preview`'s callback parameters (e.g., `wrapper`), which do not need to be static or public when provided to a `Preview` in the context of a `*.transform()` method. This makes it possible to create custom preview classes that completely encapsulate their callbacks, removing the need for separate public, static function declarations. To make transforming `Preview`s simpler, a `PreviewBuilder` utility class has also been added. Fixes flutter#175534
This change updates
Previewto be abaseclass instead offinal, allowing for developers to extendPreviewand create their own custom preview annotations.To reduce friction associated with working with
constconstructors, two new methods have been added:MultiPreview.transform()andPreview.transform(). These methods are invoked at runtime by the preview environment, allowing for developers to create or modifyPreviewinstances with non-constant values. This also relaxes restrictions aroundPreview's callback parameters (e.g.,wrapper), which do not need to be static or public when provided to aPreviewin the context of a*.transform()method. This makes it possible to create custom preview classes that completely encapsulate their callbacks, removing the need for separate public, static function declarations.To make transforming
Previews simpler, aPreviewBuilderutility class has also been added.Fixes #175534