Tool: Add search and filtering to widget preview scaffold#184023
Tool: Add search and filtering to widget preview scaffold#184023NamanGoyalK wants to merge 3 commits intoflutter:masterfrom
Conversation
|
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. |
There was a problem hiding this comment.
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.
packages/flutter_tools/templates/widget_preview_scaffold/lib/src/controls.dart.tmpl
Show resolved
Hide resolved
...tools/templates/widget_preview_scaffold/lib/src/widget_preview_scaffold_controller.dart.tmpl
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
packages/flutter_tools/templates/widget_preview_scaffold/lib/src/controls.dart.tmpl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
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:
PreviewSearchControlswidget tocontrols.dart.tmplfeaturing aTextFieldfor text-based filtering.PopupMenuButtonfilter list to toggle search inclusion for Group Name, Preview Name, Containing Script, and Containing Package.ValueNotifierstate management inwidget_preview_scaffold_controller.dart.tmplto seamlessly sync the text input and active filters with the_filteredPreviewSet.dtdServicesedge 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
///).