Repository navigation
feat: support Ruby control methods for focus, paging and tabs - #18
Merged
Merged
Conversation
Add the TextField blur invoke (Material and Cupertino) and focus the node that is actually rendered for shift_enter fields. Make PageView invoke handlers tolerate nil args, which Page#invoke sends for methods without arguments (next_page used to throw). Resolve negative and out-of-range Material Tabs move_to indexes like the Cupertino renderer and selected_index already do, instead of asserting.
This was referenced Oct 28, 2026
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.
Ruby counterpart: AdamMusa/ruflet#34
What
This is the client side of the new Ruby imperative control methods. The Ruby PR adds
focus/blur, PageView paging, Tabsmove_toand Canvas capture. Most handlers already existed in Dart; this PR fills the gaps those methods expose.blur(Material and Cupertino): newcase "blur"unfocuses the field (both the normal and theshift_enterfocus node), which also dismisses the soft keyboard.focusnow targets the node that is actually rendered:shift_enterfields use a separate focus node, andfocusused to request the unattached one.Page#invokesends"args" => nilwhen a method has no arguments, andpage_view.dartindexedargs[...]unconditionally, sonext_pagewith no arguments threw on the client._invokeMethodnow treats a non-Map payload as{}. A missingindex/valueis a no-op, as before.move_to: this handler passedargs["index"]straight toTabController.animateTo, so a negative or out-of-range index asserted in debug and corrupted the index in release. It now resolves negative indexes from the end and clamps, exactly as the Cupertino handler and Material's ownselected_indexhandling already do. That givestabs.move_to(-1)the same meaning on both designs. The spec only asked to document the Cupertino-only behavior; I fixed Material instead because the new Ruby method makes that path easy to hit.Wire protocol (invoke names and args)
focus,blur{}focus{}(unchanged handlers)go_to_pageindex, optionalduration(ms),curvejump_to_pageindexjump_tovalue(scroll offset)next_page,previous_pageduration,curve; nil args are acceptedmove_toindex(negative counts from the end, clamped), optionalduration,curvecapture/get_capture/clear_capturepixel_ratio(capture only), unchangedEvents are unchanged. Focus changes fire
focus/blur, and page and tab changes firechangewith the new index.Material vs Cupertino
blurbehaves identically onTextFormFieldandCupertinoTextField.focusworks on both designs. Dropdownfocusworks on Cupertino; on Material it only works foreditable: true, because the M3DropdownMenufocus node hascanRequestFocus = editable(inherited Flet behavior, unchanged here).move_tonow has the same index semantics on both designs.Tests
test/widgets/ruby_control_methods_test.dart(8 tests, iOS and Android):focusthenblurmove real focus and firefocus/blur. Nil args are tolerated. Ashift_enterfield focuses and blurs its own node, and unknown methods still throw.editable: true) take focus onfocusand firefocus.next_pagewith nil args turns the page, as dogo_to_pagewithduration/curve,previous_pagewith nil and with args,jump_to_page, andjump_to. Missing index/value is a no-op.selected_indexis synced andchangeevents report every landing page.move_to(2),move_to(0),move_to(-2)→ 1 andmove_to(9)→ clamped to 2. Each one syncsselected_indexand fireschange.Before the fix the new test failed with
Unknown TextField method: blur, a PageViewNoSuchMethodErroron null args, and the Android Tabs assertion.verify_pr.sh(Flutter 3.41.2), run together with the Ruby PR: