Repository navigation
feat: add SliverAppBar for CustomScrollView - #26
Merged
Merged
Conversation
Render Ruby's SliverAppBar as a sliver inside CustomScrollView. Material uses SliverAppBar (small, medium or large) with pinned, floating, snap, stretch, expanded/collapsed/toolbar heights, bottom and a FlexibleSpaceBar for flexible_space. Cupertino uses CupertinoSliverNavigationBar for medium and large, so the large title collapses into the always pinned navigation bar on scroll, and a CupertinoNavigationBar in a pinned, floating or plain sliver for small. iOS has no parallax flexible space: flexible_space scrolls as a box right below the pinned navigation bar. Both renderers read the Ruby keywords through one neutral SliverAppBarSpec, and CupertinoSliverNavigationBar is accepted as an alias. Material corrects the SDK's asserted combinations (snap without floating, collapsed_height below toolbar_height) and prints a warning naming the control id and the correction.
AdamMusa
force-pushed
the
feat/sliver-app-bar
branch
from
October 28, 2026 15:32
fcd2bb7 to
7baa2da
Compare
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.
Depends on #20 (CustomScrollView). This branch is stacked on
feat/custom-scroll-view. Until #20 merges, review only the last commit, "feat: add SliverAppBar for CustomScrollView".What
Adds
SliverAppBar, the collapsing app bar sliver forCustomScrollView(SPEC E2). On iOS it is the large title that collapses into the navigation bar on scroll.Ruby counterpart: AdamMusa/ruflet#42
Material vs Cupertino
material_sliver_app_bar.dart)cupertino_sliver_app_bar.dart, no Material symbols)variant: "small"(default)SliverAppBarCupertinoNavigationBarin aPinnedHeaderSliver(pinned), aSliverFloatingHeader(floating;snap→FloatingHeaderSnapMode.scroll, otherwise overlay), or aSliverToBoxAdapter(scrolls away)"medium"/"large"SliverAppBar.medium/.large(expanded 112 / 152, collapsed 64, plus the status bar)CupertinoSliverNavigationBar: the 52pt large title collapses into the always-pinned 44pt bar (plus the status bar)pinnedfloating,snap,stretchsnapis forced off withoutfloating(the SDK asserts), with adebugPrintwarning naming the control idSliverFloatingHeader;stretchon largeexpanded_height,collapsed_height,toolbar_heightcollapsed_heightis clamped to at leasttoolbar_height(the SDK asserts), with adebugPrintwarning naming the control id and the valuesflexible_spaceFlexibleSpaceBar(title:, background:). The title moves into it. Small defaultsexpanded_heightto 200 (+ bottom)bottom+bottom_height(48)bottom: PreferredSizebottom: PreferredSize,bottomMode: automaticleading,actionsleading,actionsleading,trailing: Row(actions)bgcolorbackgroundColorbackgroundColorcolor,elevation,scrolled_under_elevation,shadow_color,center_titleautomatically_imply_leadingprevious_page_title,border,always_show_middleborderdefaults to the SDK hairlinetransition_between_routesImplementation notes:
SliverAppBarSpec(sliver_app_bar_spec.dart), so names and defaults cannot drift between designs.adaptive_sliver_app_bar.dartpicks the renderer withPlatformControlRenderer.sliver_children.dartbuilds the SliverAppBar like the other sliver child types (D-3: not registered increateWidget). It also emits a siblingSliverAppBarFlexibleSpacesliver, which is empty except for iOSflexible_space.CupertinoSliverNavigationBaris accepted as an alias ofSliverAppBar(D-1).Tests
test/widgets/ruby_sliver_app_bar_test.dart(13 tests on a portrait phone surface):FlexibleSpaceBar.flexible_spaceandbottom: bar 126, hero box directly below, rows after it.CupertinoSliverNavigationBarrenders the canonical bar.toolbar_height70 andexpanded_height180 gives 180 → 70.flexible_space: uses aFlexibleSpaceBar, 200 + 48 tall, with the title not duplicated.Warning: SliverAppBar(<id>) …. A valid configuration prints no warning.control_renderer_matrix_test.dart: theCustomScrollViewfixture now starts with a pinned largeSliverAppBar, on iOS, Android, macOS, Windows and Linux. This proves that the iOS path builds no Material widget.control_type_test.dart: the new alias.team/verify_pr.sh(engine + Ruby worktrees, stacked on E1): PASSflutter test(Flutter 3.41.2): +733, all passed (E1's 720 + 13 new)flutter analyze lib test: No issues found