Skip to content

Conversation

@bkonyi
Copy link
Contributor

@bkonyi bkonyi commented Jan 20, 2025

flutter widget-preview start will now look for functions annotated with @Preview() within the developer's project. These functions will be used to generate
.dart_tool/widget_preview_scaffold/lib/generated_preview.dart, which inserts the returned value from each preview function into a List<WidgetPreview> returned from a previews() method that is invoked by the widget preview scaffold root.

Example generated_preview.dart:

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:foo/foo.dart' as _i1;
import 'package:foo/src/bar.dart' as _i2;
import 'package:widget_preview/widget_preview.dart';

List<WidgetPreview> previews() => [_i1.preview(), _i2.barPreview1(), _i2.barPreview2()];

… code

`flutter widget-preview start` will now look for functions annotated
with `@Preview()` within the developer's project. These functions will
be used to generate
`.dart_tool/widget_preview_scaffold/lib/generated_preview.dart`, which
inserts the returned value from each preview function into a
`List<WidgetPreview>` returned from a `previews()` method that is
invoked by the widget preview scaffold root.
@bkonyi bkonyi requested a review from matanlurey as a code owner January 20, 2025 17:35
@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. a: internationalization Supporting other languages or locales. (aka i18n) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin labels Jan 20, 2025
@github-actions github-actions bot removed a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. a: internationalization Supporting other languages or locales. (aka i18n) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin labels Jan 20, 2025
@bkonyi bkonyi removed the request for review from matanlurey January 20, 2025 17:38
@bkonyi bkonyi requested a review from andrewkolos January 20, 2025 18:25
Copy link
Contributor

@andrewkolos andrewkolos left a comment

Choose a reason for hiding this comment

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

LGTM with nitpicks

String get name => 'start';

late final PreviewDetector _previewDetector = PreviewDetector(
logger: globals.logger,
Copy link
Contributor

Choose a reason for hiding this comment

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

Turbo nit: I've noticed that we use injection instead of referencing globals for some commands (e.g. DriveCommand) but not others. For the sake of consistency, should we be using injection here as well (and keep the necessary reference to globals within executable.dart)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a good call. There's a lot of usages of globals already in this file, so I've added a TODO to follow up on this in a later PR.

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin labels Jan 24, 2025
@github-actions github-actions bot removed a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: integration_test The flutter/packages/integration_test plugin labels Jan 24, 2025
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 28, 2025
@bkonyi bkonyi added this pull request to the merge queue Jan 28, 2025
Merged via the queue into master with commit f25b4b7 Jan 28, 2025
184 checks passed
@bkonyi bkonyi deleted the generate_preview branch January 28, 2025 18:40
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 28, 2025
@matanlurey
Copy link
Contributor

reason for revert: Mid-air collision with another Flutter tool update.

@matanlurey matanlurey added the revert Autorevert PR (with "Reason for revert:" comment) label Jan 28, 2025
auto-submit bot pushed a commit that referenced this pull request Jan 28, 2025
@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Jan 28, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 28, 2025
…enerating code (#161911)" (#162327)

<!-- start_original_pr_link -->
Reverts: #161911
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: matanlurey
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Mid-air collision with another Flutter tool
update.
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: bkonyi
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {andrewkolos}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
`flutter widget-preview start` will now look for functions annotated
with `@Preview()` within the developer's project. These functions will
be used to generate
`.dart_tool/widget_preview_scaffold/lib/generated_preview.dart`, which
inserts the returned value from each preview function into a
`List<WidgetPreview>` returned from a `previews()` method that is
invoked by the widget preview scaffold root.

**Example generated_preview.dart:**

```dart
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:foo/foo.dart' as _i1;
import 'package:foo/src/bar.dart' as _i2;
import 'package:widget_preview/widget_preview.dart';

List<WidgetPreview> previews() => [_i1.preview(), _i2.barPreview1(), _i2.barPreview2()];
```
<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Jan 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 29, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 30, 2025
Roll Flutter from c1ffaa9 to b007899 (43 revisions)

flutter/flutter@c1ffaa9...b007899

2025-01-29 [email protected] Fix `Tab` linear and elastic animation blink (flutter/flutter#162315)
2025-01-29 [email protected] Pass-through `textInputAction` in `DropdownMenu` (flutter/flutter#162309)
2025-01-29 [email protected] Fix scrollUntilVisible in WidgetTester (flutter/flutter#159582)
2025-01-29 [email protected] Pass-through `maxLines` in `DropdownMenu` (flutter/flutter#161903)
2025-01-29 [email protected] fix: appbar leading width is not square for custom toolbar height (flutter/flutter#161880)
2025-01-29 [email protected] [DisplayList] Don't call Skia Ganesh methods when its not available. (flutter/flutter#162345)
2025-01-29 [email protected] Update README.md to include googler post verification steps (flutter/flutter#162272)
2025-01-29 [email protected] [engine, web] return switch expressions in many places (flutter/flutter#162336)
2025-01-29 [email protected] Update README.md to not have engine link for android (flutter/flutter#162330)
2025-01-29 [email protected] Reland "[ Widget Previews ] Add support for detecting previews and generating code (#161911)"" (flutter/flutter#162337)
2025-01-29 [email protected] Add instructions to download the Gradle wrapper to FGP readme, and add to gitignore (flutter/flutter#162332)
2025-01-29 [email protected] Fix tests to prepare for `--explicit-package-dependencies` and a bug. (flutter/flutter#162289)
2025-01-29 [email protected] Add a currently unused `runs_in_merge_queue` property to `Linux analyze`. (flutter/flutter#162335)
2025-01-28 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ Widget Previews ] Add support for detecting previews and generating code (#161911)" (flutter/flutter#162327)
2025-01-28 [email protected] Support hot restart for DDC library bundle format (flutter/flutter#162123)
2025-01-28 [email protected] Started adjusting uvs to match pixel snapping. (flutter/flutter#162049)
2025-01-28 [email protected] Refactor code inside flutter.groovy  (flutter/flutter#160250)
2025-01-28 [email protected] Table implements redepth (flutter/flutter#162282)
2025-01-28 [email protected] [ Widget Previews ] Add support for detecting previews and generating code (flutter/flutter#161911)
2025-01-28 [email protected] remove dependency on `Usage` from `Pub` class (flutter/flutter#162279)
2025-01-28 [email protected] Roll Packages from 258f6dc to 02c6fef (6 revisions) (flutter/flutter#162313)
2025-01-28 [email protected] Remove `scenario_app/android` and rename to `ios_scenario_app`. (flutter/flutter#160992)
2025-01-28 [email protected] Apparently it is illegal to use `stderr` in this project. (flutter/flutter#162294)
2025-01-28 [email protected] Fix update_engine_version_test in presence of FLUTTER_PREBUILT_ENGINE_VERSION env vars. (flutter/flutter#162270)
2025-01-28 [email protected] Add missing `properties: ...` and move to presubmit. (flutter/flutter#162170)
2025-01-27 [email protected] [Impeller] make swapchain related external fence/semaphore extensions optional. (flutter/flutter#162205)
2025-01-27 49699333+dependabot[bot]@users.noreply.github.com Bump the all-github-actions group with 2 updates (flutter/flutter#162277)
2025-01-27 [email protected] Don't depend on Dart from FML. (flutter/flutter#162271)
2025-01-27 [email protected] [DisplayList] Move nested canvas enums into their own TU. (flutter/flutter#162037)
2025-01-27 [email protected] Avoid iOS text selection crash by returning nil range (flutter/flutter#161996)
2025-01-27 [email protected] fix `felt` link to point to flutter repo instead of the engine repo (flutter/flutter#161423)
2025-01-27 [email protected] Enable the Android Engine OpenGLES/Vulkan suites. (flutter/flutter#162258)
2025-01-27 [email protected] [canvaskit] Fix debug build for CanvasKit (flutter/flutter#162198)
2025-01-27 [email protected] Roll Packages from 3d3ab7b to 258f6dc (19 revisions) (flutter/flutter#162254)
2025-01-25 [email protected] Pin `customer_testing` to the SHA specified in `tests.version` (flutter/flutter#162048)
2025-01-25 [email protected] Formalize `update_engine_version.{sh|ps1}`. (flutter/flutter#162118)
2025-01-25 [email protected] Rename 'SelectionChangedCause.scribble' to 'SelectionChangedCause.stylusHandwriting' (flutter/flutter#161518)
2025-01-25 [email protected] Don't install xcode when doing `local_engine` web builds on mac. (flutter/flutter#162164)
2025-01-25 [email protected] Force Impeller backend for `android_engine_test`, and test both OpenGLES and Vulkan (flutter/flutter#162089)
2025-01-24 [email protected] [Impeller] when a command pool has many unused buffers, reset with release resources flag. (flutter/flutter#162171)
2025-01-24 [email protected] [web] Remove HTML renderer from framework tests (flutter/flutter#162038)
2025-01-24 [email protected] [Impeller] Skip clip entity replay that cannot impact current clip. (flutter/flutter#162113)
2025-01-24 [email protected] Update Android integration test package for newer AGP (flutter/flutter#161856)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
androidseb pushed a commit to androidseb/packages that referenced this pull request Jun 8, 2025
Roll Flutter from c1ffaa9 to b007899 (43 revisions)

flutter/flutter@c1ffaa9...b007899

2025-01-29 [email protected] Fix `Tab` linear and elastic animation blink (flutter/flutter#162315)
2025-01-29 [email protected] Pass-through `textInputAction` in `DropdownMenu` (flutter/flutter#162309)
2025-01-29 [email protected] Fix scrollUntilVisible in WidgetTester (flutter/flutter#159582)
2025-01-29 [email protected] Pass-through `maxLines` in `DropdownMenu` (flutter/flutter#161903)
2025-01-29 [email protected] fix: appbar leading width is not square for custom toolbar height (flutter/flutter#161880)
2025-01-29 [email protected] [DisplayList] Don't call Skia Ganesh methods when its not available. (flutter/flutter#162345)
2025-01-29 [email protected] Update README.md to include googler post verification steps (flutter/flutter#162272)
2025-01-29 [email protected] [engine, web] return switch expressions in many places (flutter/flutter#162336)
2025-01-29 [email protected] Update README.md to not have engine link for android (flutter/flutter#162330)
2025-01-29 [email protected] Reland "[ Widget Previews ] Add support for detecting previews and generating code (#161911)"" (flutter/flutter#162337)
2025-01-29 [email protected] Add instructions to download the Gradle wrapper to FGP readme, and add to gitignore (flutter/flutter#162332)
2025-01-29 [email protected] Fix tests to prepare for `--explicit-package-dependencies` and a bug. (flutter/flutter#162289)
2025-01-29 [email protected] Add a currently unused `runs_in_merge_queue` property to `Linux analyze`. (flutter/flutter#162335)
2025-01-28 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ Widget Previews ] Add support for detecting previews and generating code (#161911)" (flutter/flutter#162327)
2025-01-28 [email protected] Support hot restart for DDC library bundle format (flutter/flutter#162123)
2025-01-28 [email protected] Started adjusting uvs to match pixel snapping. (flutter/flutter#162049)
2025-01-28 [email protected] Refactor code inside flutter.groovy  (flutter/flutter#160250)
2025-01-28 [email protected] Table implements redepth (flutter/flutter#162282)
2025-01-28 [email protected] [ Widget Previews ] Add support for detecting previews and generating code (flutter/flutter#161911)
2025-01-28 [email protected] remove dependency on `Usage` from `Pub` class (flutter/flutter#162279)
2025-01-28 [email protected] Roll Packages from 258f6dc to 02c6fef (6 revisions) (flutter/flutter#162313)
2025-01-28 [email protected] Remove `scenario_app/android` and rename to `ios_scenario_app`. (flutter/flutter#160992)
2025-01-28 [email protected] Apparently it is illegal to use `stderr` in this project. (flutter/flutter#162294)
2025-01-28 [email protected] Fix update_engine_version_test in presence of FLUTTER_PREBUILT_ENGINE_VERSION env vars. (flutter/flutter#162270)
2025-01-28 [email protected] Add missing `properties: ...` and move to presubmit. (flutter/flutter#162170)
2025-01-27 [email protected] [Impeller] make swapchain related external fence/semaphore extensions optional. (flutter/flutter#162205)
2025-01-27 49699333+dependabot[bot]@users.noreply.github.com Bump the all-github-actions group with 2 updates (flutter/flutter#162277)
2025-01-27 [email protected] Don't depend on Dart from FML. (flutter/flutter#162271)
2025-01-27 [email protected] [DisplayList] Move nested canvas enums into their own TU. (flutter/flutter#162037)
2025-01-27 [email protected] Avoid iOS text selection crash by returning nil range (flutter/flutter#161996)
2025-01-27 [email protected] fix `felt` link to point to flutter repo instead of the engine repo (flutter/flutter#161423)
2025-01-27 [email protected] Enable the Android Engine OpenGLES/Vulkan suites. (flutter/flutter#162258)
2025-01-27 [email protected] [canvaskit] Fix debug build for CanvasKit (flutter/flutter#162198)
2025-01-27 [email protected] Roll Packages from 3d3ab7b to 258f6dc (19 revisions) (flutter/flutter#162254)
2025-01-25 [email protected] Pin `customer_testing` to the SHA specified in `tests.version` (flutter/flutter#162048)
2025-01-25 [email protected] Formalize `update_engine_version.{sh|ps1}`. (flutter/flutter#162118)
2025-01-25 [email protected] Rename 'SelectionChangedCause.scribble' to 'SelectionChangedCause.stylusHandwriting' (flutter/flutter#161518)
2025-01-25 [email protected] Don't install xcode when doing `local_engine` web builds on mac. (flutter/flutter#162164)
2025-01-25 [email protected] Force Impeller backend for `android_engine_test`, and test both OpenGLES and Vulkan (flutter/flutter#162089)
2025-01-24 [email protected] [Impeller] when a command pool has many unused buffers, reset with release resources flag. (flutter/flutter#162171)
2025-01-24 [email protected] [web] Remove HTML renderer from framework tests (flutter/flutter#162038)
2025-01-24 [email protected] [Impeller] Skip clip entity replay that cannot impact current clip. (flutter/flutter#162113)
2025-01-24 [email protected] Update Android integration test package for newer AGP (flutter/flutter#161856)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
...
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
Roll Flutter from c1ffaa9 to b007899 (43 revisions)

flutter/flutter@c1ffaa9...b007899

2025-01-29 [email protected] Fix `Tab` linear and elastic animation blink (flutter/flutter#162315)
2025-01-29 [email protected] Pass-through `textInputAction` in `DropdownMenu` (flutter/flutter#162309)
2025-01-29 [email protected] Fix scrollUntilVisible in WidgetTester (flutter/flutter#159582)
2025-01-29 [email protected] Pass-through `maxLines` in `DropdownMenu` (flutter/flutter#161903)
2025-01-29 [email protected] fix: appbar leading width is not square for custom toolbar height (flutter/flutter#161880)
2025-01-29 [email protected] [DisplayList] Don't call Skia Ganesh methods when its not available. (flutter/flutter#162345)
2025-01-29 [email protected] Update README.md to include googler post verification steps (flutter/flutter#162272)
2025-01-29 [email protected] [engine, web] return switch expressions in many places (flutter/flutter#162336)
2025-01-29 [email protected] Update README.md to not have engine link for android (flutter/flutter#162330)
2025-01-29 [email protected] Reland "[ Widget Previews ] Add support for detecting previews and generating code (#161911)"" (flutter/flutter#162337)
2025-01-29 [email protected] Add instructions to download the Gradle wrapper to FGP readme, and add to gitignore (flutter/flutter#162332)
2025-01-29 [email protected] Fix tests to prepare for `--explicit-package-dependencies` and a bug. (flutter/flutter#162289)
2025-01-29 [email protected] Add a currently unused `runs_in_merge_queue` property to `Linux analyze`. (flutter/flutter#162335)
2025-01-28 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[ Widget Previews ] Add support for detecting previews and generating code (#161911)" (flutter/flutter#162327)
2025-01-28 [email protected] Support hot restart for DDC library bundle format (flutter/flutter#162123)
2025-01-28 [email protected] Started adjusting uvs to match pixel snapping. (flutter/flutter#162049)
2025-01-28 [email protected] Refactor code inside flutter.groovy  (flutter/flutter#160250)
2025-01-28 [email protected] Table implements redepth (flutter/flutter#162282)
2025-01-28 [email protected] [ Widget Previews ] Add support for detecting previews and generating code (flutter/flutter#161911)
2025-01-28 [email protected] remove dependency on `Usage` from `Pub` class (flutter/flutter#162279)
2025-01-28 [email protected] Roll Packages from 258f6dc to 02c6fef (6 revisions) (flutter/flutter#162313)
2025-01-28 [email protected] Remove `scenario_app/android` and rename to `ios_scenario_app`. (flutter/flutter#160992)
2025-01-28 [email protected] Apparently it is illegal to use `stderr` in this project. (flutter/flutter#162294)
2025-01-28 [email protected] Fix update_engine_version_test in presence of FLUTTER_PREBUILT_ENGINE_VERSION env vars. (flutter/flutter#162270)
2025-01-28 [email protected] Add missing `properties: ...` and move to presubmit. (flutter/flutter#162170)
2025-01-27 [email protected] [Impeller] make swapchain related external fence/semaphore extensions optional. (flutter/flutter#162205)
2025-01-27 49699333+dependabot[bot]@users.noreply.github.com Bump the all-github-actions group with 2 updates (flutter/flutter#162277)
2025-01-27 [email protected] Don't depend on Dart from FML. (flutter/flutter#162271)
2025-01-27 [email protected] [DisplayList] Move nested canvas enums into their own TU. (flutter/flutter#162037)
2025-01-27 [email protected] Avoid iOS text selection crash by returning nil range (flutter/flutter#161996)
2025-01-27 [email protected] fix `felt` link to point to flutter repo instead of the engine repo (flutter/flutter#161423)
2025-01-27 [email protected] Enable the Android Engine OpenGLES/Vulkan suites. (flutter/flutter#162258)
2025-01-27 [email protected] [canvaskit] Fix debug build for CanvasKit (flutter/flutter#162198)
2025-01-27 [email protected] Roll Packages from 3d3ab7b to 258f6dc (19 revisions) (flutter/flutter#162254)
2025-01-25 [email protected] Pin `customer_testing` to the SHA specified in `tests.version` (flutter/flutter#162048)
2025-01-25 [email protected] Formalize `update_engine_version.{sh|ps1}`. (flutter/flutter#162118)
2025-01-25 [email protected] Rename 'SelectionChangedCause.scribble' to 'SelectionChangedCause.stylusHandwriting' (flutter/flutter#161518)
2025-01-25 [email protected] Don't install xcode when doing `local_engine` web builds on mac. (flutter/flutter#162164)
2025-01-25 [email protected] Force Impeller backend for `android_engine_test`, and test both OpenGLES and Vulkan (flutter/flutter#162089)
2025-01-24 [email protected] [Impeller] when a command pool has many unused buffers, reset with release resources flag. (flutter/flutter#162171)
2025-01-24 [email protected] [web] Remove HTML renderer from framework tests (flutter/flutter#162038)
2025-01-24 [email protected] [Impeller] Skip clip entity replay that cannot impact current clip. (flutter/flutter#162113)
2025-01-24 [email protected] Update Android integration test package for newer AGP (flutter/flutter#161856)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants