Skip to content

feat: add CustomScrollView with sliver children - #20

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/custom-scroll-view
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/custom-scroll-view

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What

Adds the CustomScrollView control and its sliver children (SPEC E1). One scroll view can now mix lists, grids, boxes, a filler and sticky section headers that all scroll together.

Ruby counterpart: AdamMusa/ruflet#35

Rendering

CustomScrollView is design-neutral (controls/custom_scroll_view.dart, widgets layer only). It owns a ScrollController and wraps the view in ScrollableControl and ScrollNotificationControl the same way ListView does, so scroll, auto_scroll, scroll_interval, on_scroll and the scroll_to invoke work unchanged. Material and Cupertino differ only through the platform scroll physics (iOS bounces). No Material widget is built on Cupertino.

The sliver child types are built only by CustomScrollView (D-3, like DataRow or Segment). They are not registered in createWidget (controls/sliver_children.dart):

Wire type Builds
SliverList SliverList.builder / .separated / .list, or SliverFixedExtentList. It uses the same spacing, divider and on-demand rules as ListView, plus an optional SliverPadding.
SliverGrid SliverGrid.builder with the same delegate and defaults as GridView
SliverToBoxAdapter SliverToBoxAdapter(content)
SliverFillRemaining SliverFillRemaining(content). It becomes a box adapter when the view shrink-wraps, because an unbounded viewport has no remaining extent to fill.
any other control wrapped in a SliverToBoxAdapter
  • Section header (header): with sticky_header: true, the list or grid is wrapped in SliverMainAxisGroup([PinnedHeaderSliver(header), items]). The header stays pinned while its items scroll under it, then leaves with its group, like iOS Contacts or Mail. Without sticky_header, the header is a plain SliverToBoxAdapter. Both use widgets-layer classes only.
  • Background (bgcolor): wraps the section in a DecoratedSliver.
  • Reactivity: each sliver child builds in its own control context. A Ruby patch to a sliver_list (for example, a new item) rebuilds only that sliver. A visible change rebuilds the parent.

Wire keys

CustomScrollView: slivers (falls back to controls for DSL block children), horizontal, reverse, anchor, cache_extent, clip_behavior, semantic_child_count, keyboard_dismiss_behavior (manual | onDrag, underscore-tolerant), scroll, auto_scroll, scroll_interval, the common layout keys, and the event scroll.

  • SliverList: controls spacing divider_thickness item_extent padding build_controls_on_demand header sticky_header bgcolor
  • SliverGrid: controls runs_count max_extent spacing run_spacing child_aspect_ratio padding header sticky_header bgcolor
  • SliverToBoxAdapter: content
  • SliverFillRemaining: content has_scroll_body fill_overscroll
  • Every sliver child also takes key data visible.

Invoke: scroll_to (existing ScrollableControl handler).

An unbounded-height horizontal view shows the same ErrorControl as ListView.

Not in this PR

  • Pull-to-refresh and end-reached: on_refresh / refresh_* / on_end_reached are left for a follow-up once Package A's feat/pull-to-refresh and feat/end-reached merge. Those PRs are not open yet; only A0 (feat/scroll-methods: ruflet feat: add FittedBox control #31, ruflet-engine fix: answer scroll_to on the Cupertino ReorderableListView #15) is. The view already uses ListView's controller plumbing (ScrollableControl with the same controller), so the follow-up only swaps the CustomScrollView for AdaptiveRefreshScrollView and adds EndReachedListener.
  • List and grid builders: they mirror list_view.dart and grid_view.dart and live in sliver_children.dart. A1's planned scroll_slivers.dart does not exist yet. Once it lands they can be merged.

Tests

  • New test/widgets/ruby_custom_scroll_view_test.dart: 10 cases × iOS + Android = 20 tests.
    • Slivers lay out in order with exact rects: box, list, grid, auto-wrapped Text, filler.
    • The grid has a cross-axis count of 2 and honors spacing, run spacing and aspect ratio.
    • Fill-remaining height is exactly 500 of 600.
    • A sticky header stays at y = 0 while items scroll under it. At the end of its group it is pushed up, and the next header takes over.
    • A non-sticky header scrolls away.
    • List spacing, padding, bgcolor (DecoratedSliver) and item_extent are honored.
    • scroll_to(offset: -1) reaches maxScrollExtent, and on_scroll fires.
    • A Ruby patch adds an item to a SliverList. A visible: false sliver disappears.
    • Block children in controls work as a fallback.
    • The view shrink-wraps inside an unbounded Column, and the filler degrades to a box.
    • Horizontal and reverse layouts work. Unbounded horizontal height shows an ErrorControl.
    • No Material widgets appear on iOS.
  • control_renderer_matrix_test.dart fixture for CustomScrollView: sticky-header list, grid, box, auto-wrapped Text and filler, on iOS, Android, macOS, Windows and Linux.
  • team/verify_pr.sh (engine + Ruby worktrees): PASS
  • engine flutter test (Flutter 3.41.2): +720, all passed (baseline 695 + 20 focused + 5 matrix)
  • flutter analyze lib test: No issues found
  • ruflet_core: 146/146 files, 629 runs
  • wire-key audit: no findings for CustomScrollView or the Sliver* types. The audit's "NEW vs baseline: 2" are two pre-existing ReorderableListView findings whose hint text now also names custom_scroll_view.dart and sliver_children.dart. They are not new findings.

Render Ruby's CustomScrollView with SliverList, SliverGrid,
SliverToBoxAdapter and SliverFillRemaining. Lists and grids take an
optional section header that can stay pinned while its items scroll
under it (PinnedHeaderSliver in a SliverMainAxisGroup), and any other
control in slivers scrolls as one box.

The view is design neutral and reuses ScrollableControl and
ScrollNotificationControl with its own controller, so scroll,
auto_scroll, on_scroll and the scroll_to invoke behave as on ListView.
Sliver child types are built only by their parent (not registered in
createWidget) and each rebuilds on its own Ruby patches.
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