Repository navigation
feat: add page-level pull-to-refresh to View - #52
Merged
Merged
Conversation
View accepts on_refresh, the refresh_* options, on_end_reached and end_reached_threshold. An explicit view(route:, on_refresh:) is a registered control, so its refresh is dispatched to the handler and acknowledged with end_refresh on the view like any scrollable.
This was referenced Oct 28, 2026
Owner
Author
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.
Package A / A4 (
view-refresh). Engine counterpart: AdamMusa/ruflet-engine#46.Depends on #49 (A3) → #45 (A2) → #43 (A1) → #31 (A0). Review only the top commit,
feat: add page-level pull-to-refresh to View.What
ViewControlacceptson_refresh,refresh_bgcolor,refresh_color,refresh_displacement,refresh_timeout,refresh_trigger_distance,on_end_reachedandend_reached_threshold.keyboard_dismiss_behaviorcame with A3. An explicit view is a registered control, so A1'sPage#dispatch_eventensure sendsend_refreshto the view's wire id after its handler. No page.rb change.Usage
Wire and events
refreshandend_reachedtarget the View id; invokeend_refreshgoes to the View id, not the Page id 1.RefreshIndicator, Cupertino usesCupertinoSliverRefreshControl; see the engine PR.Tests:
test/view_refresh_compatibility_test.rb, 4 runs, 20 assertionsend_refreshis invoked on the view's wire id (not 1).end_reachedreaches its handler with noend_refresh.View#end_refreshtargets the view.Results (
verify_pr.sh, Flutter 3.41.2):flutter test+793: All tests passed! (A3 783 + 10)flutter analyze lib test: No issues found!D-10 investigation: the implicit page View (
page.add+page.on_refresh = …) is NOT implemented hereI checked how page-level View handlers are routed today, and ran it against
origin/main+ this stack:page.on_refresh = ->(e) {}(andpage.on_scroll = …) goes throughPage#method_missing→assign_split_prop→@view_props["on_refresh"] = <Proc>. The Proc itself is then serialized into the implicit View patch. No handler is registered and noon_refresh: trueflag is set.page.on(:refresh) { }stores a handler in@page_event_handlers, but nothing setson_refresh: trueon the implicit View, so the client never fires the event.target= its own id, which is@view_id= 20 for the implicit view.Page#dispatch_eventlooks that id up in@wire_index. The implicit view is not a registered Control, so the event is silently dropped. The same is true today foron_scrollon the implicit view.Page#invokecan address page id 1 or a registered control, but not the implicit view id 20, soend_refreshcannot be sent to it. Related pre-existing bug:Page#scroll_to,show_drawer,close_drawer,show_end_drawerandclose_end_drawerinvoke control 1 (Page). The Flutterpage.dartinvoke listener only knowstake_screenshot,push_route,get_device_infoandset_allowed_device_orientations, and throwsUnknown Page methodfor anything else. Those listeners live on the View (id 20), so these page methods currently fail on the Flutter engine.Supporting
page.on_refresh=needs three changes to page.rb's event plumbing, about 20 lines:on_*handling inassign_split_propdispatch_eventbranch that routes implicit-view targets (@views.empty? && target == @view_id) to page handlers, with the sameend_refreshensureinvokeaddressing@view_id. Fixing (c) properly also changes wherepage.scroll_to/show_drawergo.That is more than the "small page.rb change" D-10 allows, so per D-10 I stopped there. The implicit-view part needs a lead decision.
What works in this PR: an explicit
view(route:, on_refresh:). It is a registered control, so A1'sdispatch_eventensure acknowledges it with zero additional page.rb changes. This covers every app that usespage.views/routing.