Skip to content

Tool: Add search and filtering to widget preview scaffold#184023

Merged
auto-submit[bot] merged 9 commits into
flutter:masterfrom
NamanGoyalK:fix-issue-175663
Apr 8, 2026
Merged

Tool: Add search and filtering to widget preview scaffold#184023
auto-submit[bot] merged 9 commits into
flutter:masterfrom
NamanGoyalK:fix-issue-175663

Conversation

@NamanGoyalK

@NamanGoyalK NamanGoyalK commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

This PR introduces search and filtering capabilities to the Widget Preview environment UI, addressing the navigation friction when developers are working with a large number of annotated previews.

Changes introduced:

  • Added a PreviewSearchControls widget to controls.dart.tmpl featuring a TextField for text-based filtering.
  • Implemented a PopupMenuButton filter list to toggle search inclusion for Group Name, Preview Name, Containing Script, and Containing Package.
  • Added standard ValueNotifier state management in widget_preview_scaffold_controller.dart.tmpl to seamlessly sync the text input and active filters with the _filteredPreviewSet.
  • Safely handled dtdServices edge cases to ensure the search functionality works in tandem with Editor DTD service availability.
recording_2026-03-23_23.31.40.mp4

Related Issues

Fixes #175663

Pre-launch Checklist

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

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. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). 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.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 23, 2026

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

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.

Code Review

This pull request introduces search functionality for widget previews, allowing users to filter previews by a search query and specific fields such as group name, preview name, containing script, and package. The PreviewSearchControls widget, including a search text field and a filter dropdown, has been added and integrated into the WidgetPreviewControls. The WidgetPreviewScaffoldController now manages the search query and filter states, updates the filtered preview set accordingly, and disposes of new ValueNotifiers. Review comments suggest improving maintainability by centralizing the definition of search filters to reduce duplication in controls.dart.tmpl and extracting a helper method for search field notifiers in widget_preview_scaffold_controller.dart.tmpl.

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

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.

Code Review

This pull request introduces search functionality to the widget preview scaffold. It adds new UI controls for entering a search query and selecting search filters (group name, preview name, containing script, containing package). The controller has been updated to manage the search state and apply these filters to the displayed widget previews. A suggestion was made to remove a redundant call to _searchController.clear() in PreviewSearchControls, as widget.controller.updateSearchQuery('') already handles the text field update through its listener, promoting a cleaner, unidirectional data flow.

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

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.

Code Review

This pull request introduces search functionality to the widget preview scaffold. It adds new UI controls for search input and filter selection, and updates the WidgetPreviewScaffoldController to manage search state and apply filtering logic based on group name, preview name, containing script, or containing package. Feedback includes a critical type mismatch where an Iterable is assigned to a List, which needs to be converted using .toList(), and a redundant call to updateSearchQuery after _searchController.clear() which should be removed.

@bkonyi bkonyi added the CICD Run CI/CD label Mar 31, 2026

@bkonyi bkonyi left a comment

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.

Thanks for the contribution @NamanGoyalK! This looks like a great start!

We'll need to update these files in dev/integration_test/widget_preview_scaffold/ as that's the project we run tests against. In general, it's easiest to work on the widget_preview_scaffold using that project and then test it with packages/flutter_tools/tool/run_widget_preview_from_source.dart. That script will handle updating the templates based on the contents of dev/integration_test/widget_preview_scaffold/ before running the previewer.

@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 1, 2026
@NamanGoyalK

Copy link
Copy Markdown
Contributor Author

Hey @bkonyi, thanks again for the thorough review!

I've just pushed a couple of commits addressing the feedback. Also, I completely missed your note about run_widget_preview_from_source.dart handling the template syncing automatically until just now. I ended up syncing the templates manually and debugging the formatting smoke tests the hard way, definitely a lesson learned for next time! 😅

Here's what is included in the update:

Refactored the UI components to properly encapsulate the WidgetPreviewScaffoldController state within the filter configs.

Extracted the UI pieces into dedicated _SearchClearButton and _SearchFiltersMenuButton widgets.

Added a SnackBar to prevent users from silently disabling all filters at once.

Added the missing integration tests for the search controls in dev/integration_tests/widget_preview_scaffold/test/.

@bkonyi bkonyi added the CICD Run CI/CD label Apr 7, 2026
bkonyi
bkonyi previously approved these changes Apr 7, 2026

@bkonyi bkonyi left a comment

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.

Great! This looks good to me with a very minor nit, but it might be worth addressing that in a follow up PR. If all the tests pass, I think we can get this landed by the end of the day and try to make sure this is part of the next stable release.

@bkonyi bkonyi requested a review from jyameo April 7, 2026 16:33
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 7, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Apr 7, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 7, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Apr 7, 2026

@jyameo jyameo left a comment

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.

lgtm!

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 7, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 8, 2026
Merged via the queue into flutter:master with commit 113565b Apr 8, 2026
150 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 8, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Apr 8, 2026
flutter/flutter@a0924c7...05e0ae0

2026-04-08 meylis@divine.video Fix Android engine flags defaulting to true for malformed values (flutter/flutter#184631)
2026-04-08 katelovett@google.com Try one more again (flutter/flutter#184767)
2026-04-08 goderbauer@google.com Remove custom `analysis_options.yaml` from `imitation_game_flutter` (flutter/flutter#184717)
2026-04-08 victorsanniay@gmail.com Add more error handling to unawaited callsites (flutter/flutter#184526)
2026-04-08 34465683+rkishan516@users.noreply.github.com Refactor: remove material from absorb_ponter_test, container_test,  lookup_boundary_test, page_view_test, router_test, semantics_clipping_test, semantics_merge_test, shadow_test, text_test (flutter/flutter#183309)
2026-04-08 73785960+xfce0@users.noreply.github.com Remove editable_text_utils cross-imports from material and cupertino … (flutter/flutter#184519)
2026-04-08 robert.ancell@canonical.com Replace hard coded max path length with system defined one. (flutter/flutter#184697)
2026-04-08 jesswon@google.com [Re-land] Add Support For Built-in Kotlin (flutter/flutter#184745)
2026-04-08 15619084+vashworth@users.noreply.github.com Manually stop and continue LLDB breakpoints on Xcode 26.4+ (flutter/flutter#184690)
2026-04-08 katelovett@google.com Code freeze workflow (flutter/flutter#184246)
2026-04-08 737941+loic-sharma@users.noreply.github.com [Dot shorthands] Migrate examples/api/lib/widgets (flutter/flutter#183965)
2026-04-08 59215665+davidhicks980@users.noreply.github.com [cupertino.dart] Implement CupertinoMenuAnchor and CupertinoMenuItem using RawMenuAnchor (flutter/flutter#182036)
2026-04-08 87018443+mayanksharma9@users.noreply.github.com [Semantics] clarify Android header docs (flutter/flutter#183573)
2026-04-08 dacoharkes@google.com [ci] mac build_test bringup false (flutter/flutter#184738)
2026-04-08 34871572+gmackall@users.noreply.github.com Reland "Apply rect clipping to surface views" (flutter/flutter#184732)
2026-04-08 bkonyi@google.com Remove bringup label for resharded Windows tool_integration_tests shards (flutter/flutter#184721)
2026-04-08 namangoyaldev@gmail.com Tool: Add search and filtering to widget preview scaffold (flutter/flutter#184023)
2026-04-08 36861262+QuncCccccc@users.noreply.github.com Update localization from translation console (flutter/flutter#184742)
2026-04-07 rmolivares@renzo-olivares.dev Revert "Add Support For Built-in Kotlin (#184227)" (flutter/flutter#184739)
2026-04-07 34871572+gmackall@users.noreply.github.com Collect HCPP adoption analytics for flutter run/build apk/build appbundle (flutter/flutter#184225)
2026-04-07 jacksongardner@google.com Add a github workflow for reverting PRs. (flutter/flutter#184593)
2026-04-07 jesswon@google.com Add Support For Built-in Kotlin (flutter/flutter#184227)
2026-04-07 34871572+gmackall@users.noreply.github.com Revert "Apply rect clipping to surface views (#184471)" (flutter/flutter#184728)
2026-04-07 jesswon@google.com [Fix-forward] Added Compose plugin to Add-to-app Integration Test (flutter/flutter#184681)

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 bmparr@google.com,stuartmorgan@google.com 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
mbcorona pushed a commit to mbcorona/flutter that referenced this pull request Apr 15, 2026
…4023)

This PR introduces search and filtering capabilities to the Widget
Preview environment UI, addressing the navigation friction when
developers are working with a large number of annotated previews.

**Changes introduced:**
* Added a `PreviewSearchControls` widget to `controls.dart.tmpl`
featuring a `TextField` for text-based filtering.
* Implemented a `PopupMenuButton` filter list to toggle search inclusion
for Group Name, Preview Name, Containing Script, and Containing Package.
* Added standard `ValueNotifier` state management in
`widget_preview_scaffold_controller.dart.tmpl` to seamlessly sync the
text input and active filters with the `_filteredPreviewSet`.
* Safely handled `dtdServices` edge cases to ensure the search
functionality works in tandem with Editor DTD service availability.


https://github.com/user-attachments/assets/ff2eb53b-9b84-484f-826b-c0be553c8851



## Related Issues
Fixes flutter#175663

## Pre-launch Checklist

- [x] I read the [[Contributor
Guide](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23overview%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23overview))]
and followed the process outlined there for submitting PRs.
- [x] I read the [[AI contribution
guidelines](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23ai-contribution-guidelines%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23ai-contribution-guidelines))]
and understand my responsibilities, or I am not using AI tools.
- [x] I read the [[Tree
Hygiene](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md))]
wiki page, which explains my responsibilities.
- [x] I read and followed the [[Flutter Style
Guide](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md))],
including [[Features we expect every widget to
implement](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md%23features-we-expect-every-widget-to-implement%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md%23features-we-expect-every-widget-to-implement))].
- [x] I signed the
[[CLA](https://www.google.com/search?q=%5Bhttps://cla.developers.google.com/%5D(https://cla.developers.google.com/))].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[[test-exempt](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23tests%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23tests))].
- [X] I followed the [[breaking change
policy](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23handling-breaking-changes%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md%23handling-breaking-changes))]
and added [[Data Driven
Fixes](https://www.google.com/search?q=%5Bhttps://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md%5D(https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md))]
where supported.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Ben Konyi <bkonyi@google.com>
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11470)

flutter/flutter@a0924c7...05e0ae0

2026-04-08 meylis@divine.video Fix Android engine flags defaulting to true for malformed values (flutter/flutter#184631)
2026-04-08 katelovett@google.com Try one more again (flutter/flutter#184767)
2026-04-08 goderbauer@google.com Remove custom `analysis_options.yaml` from `imitation_game_flutter` (flutter/flutter#184717)
2026-04-08 victorsanniay@gmail.com Add more error handling to unawaited callsites (flutter/flutter#184526)
2026-04-08 34465683+rkishan516@users.noreply.github.com Refactor: remove material from absorb_ponter_test, container_test,  lookup_boundary_test, page_view_test, router_test, semantics_clipping_test, semantics_merge_test, shadow_test, text_test (flutter/flutter#183309)
2026-04-08 73785960+xfce0@users.noreply.github.com Remove editable_text_utils cross-imports from material and cupertino … (flutter/flutter#184519)
2026-04-08 robert.ancell@canonical.com Replace hard coded max path length with system defined one. (flutter/flutter#184697)
2026-04-08 jesswon@google.com [Re-land] Add Support For Built-in Kotlin (flutter/flutter#184745)
2026-04-08 15619084+vashworth@users.noreply.github.com Manually stop and continue LLDB breakpoints on Xcode 26.4+ (flutter/flutter#184690)
2026-04-08 katelovett@google.com Code freeze workflow (flutter/flutter#184246)
2026-04-08 737941+loic-sharma@users.noreply.github.com [Dot shorthands] Migrate examples/api/lib/widgets (flutter/flutter#183965)
2026-04-08 59215665+davidhicks980@users.noreply.github.com [cupertino.dart] Implement CupertinoMenuAnchor and CupertinoMenuItem using RawMenuAnchor (flutter/flutter#182036)
2026-04-08 87018443+mayanksharma9@users.noreply.github.com [Semantics] clarify Android header docs (flutter/flutter#183573)
2026-04-08 dacoharkes@google.com [ci] mac build_test bringup false (flutter/flutter#184738)
2026-04-08 34871572+gmackall@users.noreply.github.com Reland "Apply rect clipping to surface views" (flutter/flutter#184732)
2026-04-08 bkonyi@google.com Remove bringup label for resharded Windows tool_integration_tests shards (flutter/flutter#184721)
2026-04-08 namangoyaldev@gmail.com Tool: Add search and filtering to widget preview scaffold (flutter/flutter#184023)
2026-04-08 36861262+QuncCccccc@users.noreply.github.com Update localization from translation console (flutter/flutter#184742)
2026-04-07 rmolivares@renzo-olivares.dev Revert "Add Support For Built-in Kotlin (#184227)" (flutter/flutter#184739)
2026-04-07 34871572+gmackall@users.noreply.github.com Collect HCPP adoption analytics for flutter run/build apk/build appbundle (flutter/flutter#184225)
2026-04-07 jacksongardner@google.com Add a github workflow for reverting PRs. (flutter/flutter#184593)
2026-04-07 jesswon@google.com Add Support For Built-in Kotlin (flutter/flutter#184227)
2026-04-07 34871572+gmackall@users.noreply.github.com Revert "Apply rect clipping to surface views (#184471)" (flutter/flutter#184728)
2026-04-07 jesswon@google.com [Fix-forward] Added Compose plugin to Add-to-app Integration Test (flutter/flutter#184681)

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 bmparr@google.com,stuartmorgan@google.com 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support searching and/or filtering previews and preview groups

3 participants