Skip to content

Fix DecoratedSliver sample to avoid antialiasing gap#179848

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
brahim-guaali:fix/166822-decorated-sliver-sample
Feb 2, 2026
Merged

Fix DecoratedSliver sample to avoid antialiasing gap#179848
auto-submit[bot] merged 2 commits into
flutter:masterfrom
brahim-guaali:fix/166822-decorated-sliver-sample

Conversation

@brahim-guaali

@brahim-guaali brahim-guaali commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Description

The DecoratedSliver sample was showing an antialiasing gap between two adjacent slivers when scrolling on desktop platforms (as reported in #166822).

The fix uses a single DecoratedSliver wrapping a SliverMainAxisGroup instead of two separate DecoratedSliver widgets. This eliminates the gap while still demonstrating the widget effectively.

Fixes #166822

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.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

talabat.com contributions Talabat Flutter PRs

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Dec 14, 2025

@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 refactors the SliverDecorationExample by consolidating two DecoratedSliver widgets into a single DecoratedSliver that now wraps a SliverMainAxisGroup. This change was made to prevent antialiasing gaps that could appear between adjacent DecoratedSlivers. The original RadialGradient decoration and its associated content ('A moon on a night sky') were removed, and the LinearGradient is now applied to the single DecoratedSliver which contains both 'A night sky' and 'A blue sky' content sections within the SliverMainAxisGroup. Corresponding test cases were updated: the test for the radial gradient was removed, the test for the linear gradient was adjusted to find a single DecoratedSliver by type, and a new test was added to verify the presence of the SliverMainAxisGroup.

@brahim-guaali brahim-guaali force-pushed the fix/166822-decorated-sliver-sample branch 4 times, most recently from 27cae56 to f3dd46e Compare December 14, 2025 11:48

@dkwingsmt dkwingsmt 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 change looks good to me. Although, I wonder if there's something we can do to prevent this. Is there any reason why the gap would appear if done this way? Can we alert developers from this pattern?

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

LGTM 👍 , thanks for fixing.

I'm not sure exactly why this change stops the antialiasing gap, @brahim-guaali could you explain? This is a known issue in the framework (#14288) with similar kinds of workarounds. It looks like no one has come up with a generic solution there, but maybe for slivers there is some guidance we could give.

@justinmc justinmc added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 16, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 16, 2026
@auto-submit

auto-submit Bot commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/179848, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@brahim-guaali

brahim-guaali commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

LGTM 👍 , thanks for fixing.

I'm not sure exactly why this change stops the antialiasing gap, @brahim-guaali could you explain? This is a known issue in the framework (#14288) with similar kinds of workarounds. It looks like no one has come up with a generic solution there, but maybe for slivers there is some guidance we could give.

Antialiasing gap occurs because when two separate DecoratedSliver widgets are placed adjacent to each other, each one paints its decoration independently. Due to floating-point precision limitations and antialiasing during rendering, sub-pixel gaps can appear at the boundary between two separately-painted regions.

using a single DecoratedSliver wrapping a SliverMainAxisGroup, the gradient background is painted once as a continuous surface that spans all the child slivers. This eliminates the boundary where the gap would otherwise appear.

This is essentially the same workaround pattern used for the general antialiasing seam issue (#14288) - avoiding adjacent separately-painted regions by combining them under a single painted surface.

cc @justinmc

@brahim-guaali

brahim-guaali commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

The change looks good to me. Although, I wonder if there's something we can do to prevent this. Is there any reason why the gap would appear if done this way? Can we alert developers from this pattern?

See my reply to @justinmc above for why the gap appears.

Alerting developers: This is part of the broader antialiasing seam issue (#14288). Potential mitigations like documentation updates or lint rules could be explored in separate efforts. For this PR, fixing the sample ensures the docs don't showcase a problematic pattern.

CC @dkwingsmt

@justinmc justinmc requested a review from Piinks January 20, 2026 23:17
@Piinks Piinks removed their request for review January 20, 2026 23:42
@brahim-guaali

brahim-guaali commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

@ksokolovskyi @AbdeMohlbi any chance to switch this to auto submit?

The previous sample used two adjacent DecoratedSlivers with gradients
that met at the same color, causing a visible antialiasing gap when
scrolling on desktop platforms.

This change uses a single DecoratedSliver with SliverMainAxisGroup to
wrap the content, eliminating the gap. The moon effect (RadialGradient)
is preserved by layering it as a Container decoration on top of the
DecoratedSliver's LinearGradient background.

Fixes flutter#166822
@Piinks Piinks force-pushed the fix/166822-decorated-sliver-sample branch from 82c7ff0 to 3f969f0 Compare February 2, 2026 16:03
@Piinks

Piinks commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

I've rebased this so it can land - the base commit was over 7 days old. Should be good to go now!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 2, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Feb 2, 2026
@zijiehe-google-com

Copy link
Copy Markdown
Contributor

I saw you tagged me in several PRs and they are all taken care of. Feel free to at me again if anything I can help.

Thank you.

Merged via the queue into flutter:master with commit c305f1f Feb 2, 2026
46 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 2, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 2, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Feb 2, 2026
flutter/flutter@9eafba4...c305f1f

2026-02-02 [email protected] Fix DecoratedSliver sample to avoid antialiasing gap (flutter/flutter#179848)
2026-02-02 [email protected] [Android] Add predictive back support for FlutterFragment and FlutterFragmentActivity (flutter/flutter#181124)
2026-02-02 [email protected] Roll Packages from 510dd40 to 837dbbd (3 revisions) (flutter/flutter#181811)
2026-02-02 [email protected] Roll Dart SDK from 434c5c6d1889 to 1aa8f2de7587 (1 revision) (flutter/flutter#181810)
2026-02-02 [email protected] Use null-aware elements in cupertino/list_tile.dart (flutter/flutter#181243)
2026-02-02 [email protected] Use null-aware elements in material/dialog.dart (flutter/flutter#181244)
2026-02-02 [email protected] Use null-aware spread in cupertino/app.dart (flutter/flutter#181585)
2026-02-02 [email protected] Use null-aware spread in material/app.dart (flutter/flutter#181586)
2026-02-02 [email protected] Roll Dart SDK from 84abc8d58ec8 to 434c5c6d1889 (1 revision) (flutter/flutter#181800)
2026-02-02 [email protected] Roll Skia from c14c5b243395 to 43fa79e1c51f (8 revisions) (flutter/flutter#181797)
2026-02-02 [email protected] Roll Skia from 4ee9eb659ae0 to c14c5b243395 (1 revision) (flutter/flutter#181780)
2026-02-02 [email protected] Roll Fuchsia Linux SDK from nI52U4LJMrBv8G1M9... to 1L4m9qCikk-JzrNWE... (flutter/flutter#181779)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Feb 6, 2026
## Description

The DecoratedSliver sample was showing an antialiasing gap between two
adjacent slivers when scrolling on desktop platforms (as reported in
flutter#166822).

The fix uses a single `DecoratedSliver` wrapping a `SliverMainAxisGroup`
instead of two separate `DecoratedSliver` widgets. This eliminates the
gap while still demonstrating the widget effectively.

Fixes flutter#166822

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md


[![talabat.com
contributions](https://img.shields.io/badge/talabat.com-contributions-FF5A00?style=flat&logo=flutter&logoColor=white)](https://www.talabat.com)
[![Talabat Flutter
PRs](https://img.shields.io/badge/Talabat_Flutter_PRs-10%20merged-97ca00?style=flat&logo=flutter&logoColor=white)](https://github.com/search?q=org%3Aflutter+talabat&type=pullrequests)
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
## Description

The DecoratedSliver sample was showing an antialiasing gap between two
adjacent slivers when scrolling on desktop platforms (as reported in
flutter#166822).

The fix uses a single `DecoratedSliver` wrapping a `SliverMainAxisGroup`
instead of two separate `DecoratedSliver` widgets. This eliminates the
gap while still demonstrating the widget effectively.

Fixes flutter#166822

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md


[![talabat.com
contributions](https://img.shields.io/badge/talabat.com-contributions-FF5A00?style=flat&logo=flutter&logoColor=white)](https://www.talabat.com)
[![Talabat Flutter
PRs](https://img.shields.io/badge/Talabat_Flutter_PRs-10%20merged-97ca00?style=flat&logo=flutter&logoColor=white)](https://github.com/search?q=org%3Aflutter+talabat&type=pullrequests)
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
## Description

The DecoratedSliver sample was showing an antialiasing gap between two
adjacent slivers when scrolling on desktop platforms (as reported in
flutter#166822).

The fix uses a single `DecoratedSliver` wrapping a `SliverMainAxisGroup`
instead of two separate `DecoratedSliver` widgets. This eliminates the
gap while still demonstrating the widget effectively.

Fixes flutter#166822

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md


[![talabat.com
contributions](https://img.shields.io/badge/talabat.com-contributions-FF5A00?style=flat&logo=flutter&logoColor=white)](https://www.talabat.com)
[![Talabat Flutter
PRs](https://img.shields.io/badge/Talabat_Flutter_PRs-10%20merged-97ca00?style=flat&logo=flutter&logoColor=white)](https://github.com/search?q=org%3Aflutter+talabat&type=pullrequests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos 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.

[docs] Rendering issue with DecoratedSliver sample

5 participants