Skip to content

Add SliverClipRect and SliverClipRRect - #179003

Merged
auto-submit[bot] merged 30 commits into
flutter:masterfrom
sncf-connect-tech:sliver_clip_rect
Aug 20, 2026
Merged

auto-submit[bot] merged 30 commits into
flutter:masterfrom
sncf-connect-tech:sliver_clip_rect

Conversation

@manu-sncf

@manu-sncf manu-sncf commented Nov 24, 2025 •

Copy link
Copy Markdown
Contributor

Fix #179002.

Pre-launch Checklist

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Nov 24, 2025
@manu-sncf
manu-sncf force-pushed the sliver_clip_rect branch 5 times, most recently from ee0ecb6 to bb892ee Compare November 24, 2025 16:03
@manu-sncf
manu-sncf marked this pull request as ready for review November 24, 2025 16:33
@manu-sncf
manu-sncf force-pushed the sliver_clip_rect branch 5 times, most recently from a166658 to e97348b Compare December 1, 2025 21:20
@zemanux

zemanux commented Dec 4, 2025 •

Copy link
Copy Markdown
Member

The push (c9db9e0) is for migration from @manu-sncf to @zemanux

@Piinks
Piinks self-requested a review December 9, 2025 23:09
@zemanux
zemanux force-pushed the sliver_clip_rect branch 2 times, most recently from f259a25 to a2ed28f Compare December 12, 2025 18:16
@zemanux

zemanux commented Dec 12, 2025 •

Copy link
Copy Markdown
Member

Last commit for rebase and synchronization of getMaxPaintRect.

RenderSliver.getMaxPaintRect was moved up to RenderSliver as it is also needed for PR #179802, the logic was therefore duplicated here.

I added a new example demonstrating the key capabilities of this new widget:

sliver_clip_rect.mp4
Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: MyApp()));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) => Scaffold(
    body: DecoratedBox(
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topCenter,
          end: Alignment.bottomCenter,
          colors: <Color>[Colors.blue.shade200, Colors.blue.shade800],
        ),
      ),
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 32),
        child: CustomScrollView(
          physics: const BouncingScrollPhysics(),
          reverse: false,
          slivers: <Widget>[
            SliverClipRRect(
              borderRadius: BorderRadius.circular(12),
              sliver: const SliverAppBar(
                pinned: true,
                stretch: true,
                title: Text('Group Clipping'),
                backgroundColor: Colors.transparent,
              ),
            ),
            SliverClipRRect(
              clipOverlap: false,
              borderRadius: BorderRadius.circular(12),
              sliver: const PinnedHeaderSliver(
                child: Material(
                  color: Colors.amber,
                  child: ListTile(
                    title: Text('This is a PinnedHeaderSliver', style: TextStyle(color: Colors.white)),
                  ),
                ),
              ),
            ),
            ...List.generate(
              2,
              (_) => SliverPadding(
                padding: const EdgeInsets.all(16),
                sliver: SliverClipRRect(
                  // clipOverlap: false,
                  borderRadius: BorderRadius.circular(12),
                  sliver: DecoratedSliver(
                    decoration: const BoxDecoration(color: Colors.purple),
                    sliver: SliverMainAxisGroup(
                      slivers: <Widget>[
                        const PinnedHeaderSliver(
                          child: ListTile(
                            title: Text('Pinned Header', style: TextStyle(color: Colors.white)),
                          ),
                        ),
                        SliverClipRect(
                          sliver: SliverList.builder(
                            itemCount: 20,
                            itemBuilder: (BuildContext context, int index) => Material(
                              type: MaterialType.transparency,
                              child: ListTile(
                                title: Text('Item $index', style: const TextStyle(color: Colors.white)),
                                onTap: () {},
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    ),
  );
}

// class _DecoratedSliver extends StatelessWidget {
//   const _DecoratedSliver({this.isEnabled = true, required this.sliver});

//   final bool isEnabled;
//   final Widget sliver;

//   @override
//   Widget build(BuildContext context) => isEnabled
//       ? DecoratedSliver(
//           decoration: BoxDecoration(
//             border: Border.all(),
//             borderRadius: BorderRadius.circular(8),
//             gradient: const LinearGradient(
//               begin: Alignment.topCenter,
//               end: Alignment.bottomCenter,
//               colors: [Colors.blue, Colors.purple],
//             ),
//           ),
//           sliver: sliver,
//         )
//       : sliver;
// }

@zemanux

zemanux commented Dec 19, 2025

Copy link
Copy Markdown
Member

I've rebased this PR on top of #180074 to use the shared getMaxPaintRect.
Cc @Piinks

@zemanux
zemanux force-pushed the sliver_clip_rect branch 2 times, most recently from 24855d6 to 38ce420 Compare December 29, 2025 09:53
@Piinks

Piinks commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for separating out the change to ad the method to RenderSliver. I will hold off on reviewing this and #179802 until the dependent change, #180074, is ready. :)

@zemanux

zemanux commented Aug 19, 2026

Copy link
Copy Markdown
Member

Thanks @zemanux! I think this needs to be rebased to resolve the CI failures. Normally I would be able to do that here in the PR directly, but the settings we discussed earlier prevent it. Can you rebase so we can merge?

Done !

@auto-submit

auto-submit Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/179003, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 2 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@Renzo-Olivares Renzo-Olivares 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.

RE-LGTM

@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.

Re-LGTM 🤞

@Piinks

Piinks commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Hoooray!! So glad to see this finally merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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.

Add SliverClipRect and SliverClipRRect to the widgets library

7 participants