Repository navigation
feat: add pull-to-refresh to scrollable controls - #27
Merged
Merged
Conversation
ListView, GridView and Column with on_refresh render a CustomScrollView with a Material RefreshIndicator or, on Cupertino, a CupertinoSliverRefreshControl. A shared RefreshCoordinator fires the refresh event and keeps the spinner until Ruby invokes end_refresh, with refresh_timeout (30 s) as a safety net. The slivers reproduce the box ListView/GridView layout (padding, media insets, spacing, separators, item extents) so geometry is unchanged, and the scroll controller is shared so scroll, auto_scroll, scroll_to and on_scroll keep working.
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 / A1 (
pull-to-refresh, P0). Ruby counterpart: AdamMusa/ruflet#43. Implements lead decision D-2.What
ListView,GridViewandColumnwithon_refreshrender aCustomScrollViewwith a native refresh control.RefreshIndicatorCupertinoSliverRefreshControlas the first sliver, with bouncing physics. No Material widget is used.A shared
RefreshCoordinatorfiresrefreshand keeps the spinner until Ruby invokesend_refresh. Ruby sends that automatically once the handler returns (D-2).refresh_timeout(default 30 s) is the safety net if the acknowledgement never arrives.New files:
refresh_coordinator.dart,scroll_slivers.dart,material_refresh_scroll_view.dart,cupertino_refresh_scroll_view.dart,adaptive_refresh_scroll_view.dart.scroll_slivers.dartrebuilds the exact sliversListView/GridViewbuild internally: explicitpadding, or theBoxScrollViewmain-axis media padding when padding is nil, plus spacing/separators,item_extent, prototype,build_controls_on_demand.grid_view.dartnow takes its delegate fromgridDelegateForandlist_view.dartits separator fromlistSeparator.scroll,auto_scroll,scroll_toandon_scrollkeep working on a refreshable list. The refresh path is an early return inside the existingLayoutBuilder, so the boxListView/GridViewcode is untouched apart from a shared_scrollable()wrapper._RefreshableColumnthat owns the controller. The Column sits in a box at least one viewport tall, soalignmentstill works. If a child hasexpand, the box is exactly one viewport tall soExpandedkeeps flexing; an unbounded box would throw.reverselists andwrap: trueColumns ignoreon_refreshand log onedebugPrint.Ruby usage
Wire
on_refresh→ eventrefresh, payloadnullrefresh_colorRefreshIndicator.colorCupertinoActivityIndicatorcolor (copy of the SDK builder)refresh_bgcolorbackgroundColorrefresh_displacement(40)displacementrefresh_trigger_distance(100)refreshTriggerPullDistance(kept ≥ the 60 px indicator extent)refresh_timeout(ms or{seconds:}, 30 s)end_refresh(no args)end_refreshis only answered by the coordinator's listener. Other names returnnull, soScrollableControl'sscroll_tolistener keeps working.Tests:
test/widgets/ruby_refresh_test.dart, 33 tests on iOS and Androidend_refreshcompletes it, other invoke names are ignored,refresh_timeoutworks, and dispose completes the refresh and unregisters the listener.refresh.RefreshIndicator+RefreshProgressIndicator. Cupertino showsCupertinoSliverRefreshControl+CupertinoActivityIndicator, with no Material widget before, during or after the pull.end_refresh, then settles back to the top, and a second pull refreshes again.on_refresh(padding, spacing, run_spacing).paddingis nil.alignment: center+ spacing positions are unchanged.expandchildren keep their flex height.refresh_timeout: 100ends the spinner without Ruby.on_refresh.scroll_toworks on a refreshable list.The matrix fixtures are unchanged, as the spec says. The no-Material-on-Cupertino rule for the refresh path is asserted in the focused test with a stricter predicate that includes
RefreshIndicatorandProgressIndicator.verify_pr.sh(Flutter 3.41.2):flutter analyze lib test: No issues found!spacing/divider_thicknesslines; only their "literal elsewhere" hint changed, because those literals moved intoscroll_slivers.dart. There are no new findings, and every new refresh key is read.Notes and deviations from SPEC
boxSliveruses a min-heightSliverToBoxAdapterinstead ofSliverFillRemaining(hasScrollBody: false).SliverFillRemainingmeasures the child's intrinsic height, which throws for LayoutBuilder-based children (ListView, GridView, ResponsiveRow, Markdown…) and costs an extra layout pass.expand: trueis still recommended.scroll_slivers.dartandadaptive_refresh_scroll_view.dart.