Repository navigation
fix: support SearchBar open_view and close_view on iOS - #70
Merged
AdamMusa merged 1 commit intoNov 2, 2026
Merged
Conversation
The Cupertino SearchBar rejected open_view/close_view with 'Unknown SearchBar method'. iOS has no separate search view, so map them to the native search-controller behavior: open_view activates the search field (focus, suggestions listed even before typing) and close_view optionally sets the query, writes value without a change event (as Material does) and cancels the search. Leaving the field also ends an opened view.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wave-3 item 2. Engine-only.
Problem
On iOS and macOS,
search_bar.open_view/close_viewfailed: the Cupertino SearchBar's invoke handler rejected them withUnknown SearchBar method. This was an immediate error, not a timeout, so the generic fix #59 does not apply.Native mapping
iOS has no separate full-screen search view like Material's
SearchAnchor. The native pattern isUISearchController: activating the search field (first responder) shows the results, and cancelling resigns it. So:open_viewCupertinoSearchTextFieldand lists every suggestion (controls) even before typing. No-op if disabled or already open.SearchController.openView()close_view(text)textis given, sets the query and writesvaluewithout achangeevent (same as Material); then ends the view and resigns focus. No-op if the search isn't active; nil text keeps the query.closeView(text)+ valueTyping still shows suggestions only once there is text, as before. A view opened by
open_viewends when the field loses focus.Events:
focusandblurfire as the field gains and loses focus; there is no new event.Tests
test/widgets/ruby_search_bar_view_test.dart(7 tests):open_view: the field is focused, both suggestions show below the field with empty text, andfocusfires.close_view({text: "Apple"}): unfocused, suggestions hidden, controller text andvalueare "Apple", and onlyblurfires (nochange).close_viewwith nil: keeps the query "Ban".close_viewon a closed search changes nothing and fires nothing.open_viewon a disabled bar neither focuses nor shows suggestions.open_viewshows the suggestions, andclose_view(text: "Banana")closes the view and setsvalue, as before.Before the fix, all 5 iOS tests failed with
Unknown SearchBar method: open_view/close_view.verify_pr.sh(Flutter 3.41.2):