Skip to content

fix: support SearchBar open_view and close_view on iOS - #70

Merged
AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/cupertino-search-bar-open-close
Nov 2, 2026
Merged

AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/cupertino-search-bar-open-close

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Wave-3 item 2. Engine-only.

Problem

On iOS and macOS, search_bar.open_view / close_view failed: the Cupertino SearchBar's invoke handler rejected them with Unknown 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 is UISearchController: activating the search field (first responder) shows the results, and cancelling resigns it. So:

Method iOS Material (unchanged)
open_view focuses the CupertinoSearchTextField and lists every suggestion (controls) even before typing. No-op if disabled or already open. SearchController.openView()
close_view(text) if text is given, sets the query and writes value without a change event (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) + value

Typing still shows suggestions only once there is text, as before. A view opened by open_view ends when the field loses focus.

Events: focus and blur fire as the field gains and loses focus; there is no new event.

Tests

test/widgets/ruby_search_bar_view_test.dart (7 tests):

  • iOS open_view: the field is focused, both suggestions show below the field with empty text, and focus fires.
  • iOS close_view({text: "Apple"}): unfocused, suggestions hidden, controller text and value are "Apple", and only blur fires (no change).
  • iOS close_view with nil: keeps the query "Ban".
  • iOS no-ops: close_view on a closed search changes nothing and fires nothing. open_view on a disabled bar neither focuses nor shows suggestions.
  • iOS focus loss: an opened view closes. A later plain tap focuses the field, but suggestions still wait for text.
  • Material: open_view shows the suggestions, and close_view(text: "Banana") closes the view and sets value, 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):

PASS engine:ruflet flutter test         +702: All tests passed!
PASS engine:ruflet analyze              No issues found!
RESULT: PASS

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant