Skip to content

feat: add raw sliver app bar#182925

Closed
rkishan516 wants to merge 1 commit into
flutter:masterfrom
rkishan516:raw-sliver-appbar
Closed

feat: add raw sliver app bar#182925
rkishan516 wants to merge 1 commit into
flutter:masterfrom
rkishan516:raw-sliver-appbar

Conversation

@rkishan516

Copy link
Copy Markdown
Contributor

This PR adds RawSliverAppBar widget and uses it for SliverAppBar which is material version.

Part of: #182702

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Feb 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new RawSliverAppBar widget to abstract the non-Material logic from SliverAppBar. The existing SliverAppBar is refactored to use this new raw widget, which simplifies its implementation. New comprehensive tests for RawSliverAppBar are also added. The changes improve modularity and separation of concerns. I've included one suggestion to improve performance by memoizing a builder function.

@justinmc justinmc requested a review from Piinks February 26, 2026 22:57
@justinmc

Copy link
Copy Markdown
Contributor

This spun out of this comment on another PR: #182702 (comment)

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach LGTM as long as tests still pass, but I'll defer to @Piinks . Thanks for jumping on this refactor @rkishan516.

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rkishan516 I really appreicate all of the work you have put in here, this is not trivial change. However, SliverAppBar is a widget we listed in #53059 as one we do not want to refactor to a Raw widget.

These are some of the reasons we listed there:
- Highly complex and material-specific
- SliverPersistentHeader, its base class is already in widgets, We added several atomic sliver header widgets last year that are meant to replace the SliverAppBar behemoth through composition in the widgets layer.
- SliverResizingHeader: Pins its child and resizes it from its max extent to its min extent when scrolled
- SliverFloatingHeader: Hides the child when the user scrolls backwards and shows its child when the user scrolls forward
- PinnedHeaderSliver: Keeps its child pinned to the top of the scroll view.

The other listed slivers are intended to provide that more basic support for building dynamic headers that can be composed for various behaviors.
If we were to add more slivers to the widgets layer that handle header-like presentations, they should be specifically scoped to features (perhaps dynamic sizing) that are not already supported.

BuildContext context, {
required double toolbarOpacity,
required double bottomOpacity,
required bool isScrolledUnder,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a material convention.

Comment on lines +2008 to +2011
final double minExtent;

/// Maximum height of the app bar when fully expanded.
final double maxExtent;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that SliverAppBar cannot be dynamically sized is a long time pain point and not something we would want to continue in a new basic widget. (#18345)

@rkishan516

Copy link
Copy Markdown
Contributor Author

Makes sense. Closing it then.

@rkishan516 rkishan516 closed this Mar 7, 2026
@rkishan516 rkishan516 deleted the raw-sliver-appbar branch March 8, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants