Repository navigation
feat: add page-level pull-to-refresh to View - #46
Merged
Merged
Conversation
A View with on_refresh renders its body as a refreshable CustomScrollView (RefreshIndicator on Material, CupertinoSliverRefreshControl on Cupertino) that is at least one viewport tall, so alignment, the app bar, drawers and the FAB are unchanged and expand children keep flexing. on_end_reached works on a scrolling View too.
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.
Package A / A4 (
view-refresh). Ruby counterpart: AdamMusa/ruflet#52.Depends on #36 (A3) → #30 (A2) → #27 (A1). It reuses
AdaptiveRefreshScrollView,boxSliver,EndReachedListenerand the keyboard parser. Review only the top commit,feat: add page-level pull-to-refresh to View.What (explicit View)
view.dart, a View withon_refreshswaps the body'sScrollableControl(wrapIntoScrollableView: true, child: column)forScrollableControl(scrollController: …, child: AdaptiveRefreshScrollView(slivers: [boxSliver(column)])).vertical_alignment/horizontal_alignmentlay out as before. The View padding stays on the outer Container.expand, the box is exactly one viewport tall soExpandedkeeps flexing.PlatformPageScaffold.ScrollableControlgets its own key, so togglingon_refreshat runtime doesn't reuse a state bound to the other controller.scroll_slivers.dartnow keeps only the sharedpaddedSliver/sliverItem. List slivers move tolist_view_sliver.dart, grid slivers togrid_view_sliver.dart, andboxSliver/hasExpandedChildtobox_sliver.dart(Column, View). The wire-key audit attributes every read in a renderer's import closure to that control. Once View imported the old combined file, it flagged a false near-missaspect_ratio~child_aspect_ratioon View and cross-reads such asruns_counton ListView. With the split, each control's closure only reads its own Ruby keys. There is no behavior change.on_end_reachedandkeyboard_dismiss_behaviorwork on the View too.on_end_reachedneeds a scroll view, so the View must havescroll:oron_refresh.Ruby usage
Wire
on_refresh,refresh_color,refresh_bgcolor,refresh_displacement,refresh_trigger_distance,refresh_timeout,on_end_reached,end_reached_thresholdandkeyboard_dismiss_behavior, with the same meaning as A1–A3.refreshandend_reachedon the View's id. Invokeend_refreshon the View's id.Material vs Cupertino
RefreshIndicatorunder the Material app bar.CupertinoSliverRefreshControlunder theCupertinoNavigationBar. The test asserts there is nomaterial.Theme/Material widget anywhere on Cupertino.Tests:
test/widgets/ruby_view_refresh_test.dart, 10 tests on both designs, with a real Page → View → PlatformApp fixtureon_refresh.refresh(exactly once), the spinner shows, Viewend_refreshsettles it back, and the first child returns to its original position.on_end_reachedon a short scrolling View fires once (withscroll: autoand withon_refresh).expandchildren keep flexing in a refreshable 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.