Skip to content

Fix RenderSliverPadding setter assertion#187353

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
fallintoplace:fix/render-sliver-padding-assert
Jul 7, 2026
Merged

Fix RenderSliverPadding setter assertion#187353
auto-submit[bot] merged 5 commits into
flutter:masterfrom
fallintoplace:fix/render-sliver-padding-assert

Conversation

@fallintoplace

@fallintoplace fallintoplace commented May 30, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Fixes RenderSliverPadding.padding so the setter validates the incoming value instead of re-validating the current padding.

Why?

The constructor already rejects negative padding values, but the setter was asserting on the old field value. That meant assigning negative padding through the setter could slip past the intended debug check.

Tests

  • ./bin/flutter test packages/flutter/test/rendering/sliver_cache_test.dart

Notes

This also adds a regression test that verifies the setter throws an assertion for negative padding.

Fixes #187527

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels May 30, 2026
@fallintoplace
fallintoplace marked this pull request as ready for review May 30, 2026 20:09

@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 corrects an assertion in the RenderSliverPadding setter to check the incoming value instead of the existing padding property. Additionally, a unit test has been added to verify that setting negative padding triggers an assertion error. There are no review comments, and I have no feedback to provide.

@Piinks
Piinks self-requested a review June 2, 2026 22:18
@Piinks

Piinks commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Hey @fallintoplace thanks for contributing! Is there an open issue for this?

@fallintoplace

Copy link
Copy Markdown
Contributor Author

Dear @Piinks, there isn't any, should I create one?

@Piinks

Piinks commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Dear @Piinks, there isn't any, should I create one?

Yes please file an issue, thank you!

@Piinks Piinks added the CICD Run CI/CD label Jun 3, 2026
@fallintoplace

Copy link
Copy Markdown
Contributor Author

@Piinks I will file the corresponding issue later today.

expect(children.sublist(42, 60).every((RenderBox r) => r.attached), true);
});

test('RenderSliverPadding setter asserts for negative padding', () {

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.

Thank you for contribution! This looks like a good clean minimal fix, but I think this test ought to be in slivers_padding_test.dart rather than in cache

There also seems to be a CI failure from this new test

   info • Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation • packages/flutter/test/rendering/sliver_cache_test.dart:502:11 • omit_obvious_local_variable_types

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 8, 2026
@Hari-07 Hari-07 added the CICD Run CI/CD label Jun 9, 2026
@Hari-07

Hari-07 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Looks like the test added still fails

Viewport+SliverPadding changing padding to negative asserts

The following TestFailure was thrown running a test:
Expected: throws <Instance of 'AssertionError'>
  Actual: <Closure: () => Future<void>>
   Which: returned a Future that emitted <null>

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 9, 2026
@Hari-07 Hari-07 added the CICD Run CI/CD label Jun 9, 2026
@Hari-07

Hari-07 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@fallintoplace I request you to go through the AI Contribution Guidelines

Instead of simply relaying comments to AI without checking if the change made is fixing the issue

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 9, 2026
@Hari-07 Hari-07 added the CICD Run CI/CD label Jun 9, 2026
@Hari-07

Hari-07 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor
01:39 +5630 ~121 -1: C:/b/s/w/ir/x/w/flutter/packages/flutter/test/widgets/slivers_padding_test.dart: (tearDownAll) [E]
  Expected: leak free
    Actual: <Instance of 'Leaks'>
     Which: contains leaks:
            # The text is generated by leak_tracker.
            # For leak troubleshooting tips open:
            # https://github.com/flutter/flutter/blob/main/docs/contributing/testing/Leak-tracking.md
            notDisposed:
              total: 5
              objects:
                _ViewportElement:
                  test: Viewport+SliverPadding changing padding to negative asserts
                  identityHashCode: 692869396
                RenderViewport:
                  test: Viewport+SliverPadding changing padding to negative asserts
                  identityHashCode: 286981433
                SingleChildRenderObjectElement:
                  test: Viewport+SliverPadding changing padding to negative asserts
                  identityHashCode: 1019697483
                RenderSliverPadding:
                  test: Viewport+SliverPadding changing padding to negative asserts
                  identityHashCode: 407477882
                OffsetLayer:
                  test: Viewport+SliverPadding changing padding to negative asserts
                  identityHashCode: 1063275793
            
            
  
  package:matcher                                              expect
  package:leak_tracker_testing/src/leak_testing.dart 69:24     LeakTesting.collectedLeaksReporter.<fn>
  package:leak_tracker_flutter_testing/src/testing.dart 74:37  maybeTearDownLeakTrackingForAll
  ===== asynchronous gap ===========================
  dart:async                                                   _CustomZone.registerBinaryCallback
  package:flutter_test/src/test_compat.dart 302:3              _tearDownForTestFile

You can run flutter test locally with --dart-define LEAK_TRACKING=true to verify this locally

@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 10, 2026
@Hari-07 Hari-07 added the CICD Run CI/CD label Jun 11, 2026
@fallintoplace

Copy link
Copy Markdown
Contributor Author

@Hari-07 Is there anything I can do to help this land? Thank you for your attention.

@Piinks Piinks removed the CICD Run CI/CD label Jul 6, 2026

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

This LGTM. In the future, please ensure to keep the PR template in place to fill out the pre-flight checklist.

@Piinks
Piinks force-pushed the fix/render-sliver-padding-assert branch from 1ddbb40 to d6a8531 Compare July 6, 2026 22:57
@Piinks Piinks added the CICD Run CI/CD label Jul 6, 2026
@Hari-07 Hari-07 added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 7, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 7, 2026
Merged via the queue into flutter:master with commit 5c6367c Jul 7, 2026
97 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 7, 2026
Rusino pushed a commit to Rusino/flutter that referenced this pull request Jul 7, 2026
## What does this change?
Fixes `RenderSliverPadding.padding` so the setter validates the incoming
`value` instead of re-validating the current padding.

## Why?
The constructor already rejects negative padding values, but the setter
was asserting on the old field value. That meant assigning negative
padding through the setter could slip past the intended debug check.

## Tests
- `./bin/flutter test
packages/flutter/test/rendering/sliver_cache_test.dart`

## Notes
This also adds a regression test that verifies the setter throws an
assertion for negative padding.

Fixes flutter#187527
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 8, 2026
…12137)

Manual roll Flutter from 6995038d96ef to 91939cc4db78 (48 revisions)

Manual roll requested by [email protected]

flutter/flutter@6995038...91939cc

2026-07-07 [email protected] Roll Skia from 80ae1deed9ed to 075fbe4778d9 (6 revisions) (flutter/flutter#189067)
2026-07-07 [email protected] Bump customer testing version for new registrants (flutter/flutter#189070)
2026-07-07 [email protected] Roll Packages from fc00ceb to 92525f5 (2 revisions) (flutter/flutter#189069)
2026-07-07 [email protected] fix android semantics integration test hangs due to postframe callback (flutter/flutter#189043)
2026-07-07 [email protected] Bump goldctl (flutter/flutter#189030)
2026-07-07 [email protected] Roll Skia from 71db7c06c5fe to 80ae1deed9ed (2 revisions) (flutter/flutter#189060)
2026-07-07 [email protected] Collect analytics on AI agent usage (flutter/flutter#187630)
2026-07-07 [email protected] Roll Skia from 125a76cc4cf3 to 71db7c06c5fe (4 revisions) (flutter/flutter#189054)
2026-07-07 [email protected] Roll Dart SDK from 70577d6f2bba to c648e3429d76 (1 revision) (flutter/flutter#189052)
2026-07-07 [email protected] Fix RenderSliverPadding setter assertion (flutter/flutter#187353)
2026-07-07 [email protected] Roll Skia from 2dde156aec3e to 125a76cc4cf3 (3 revisions) (flutter/flutter#189037)
2026-07-07 [email protected] Explain asynchronous causes in the setState() called after dispose() error (flutter/flutter#187294)
2026-07-07 [email protected] Roll Skia from 7dccd1e79a5b to 2dde156aec3e (2 revisions) (flutter/flutter#189035)
2026-07-07 [email protected] Add `STRING_CATALOG_GENERATE_SYMBOLS = YES;` (flutter/flutter#188163)
2026-07-07 [email protected] Print warnings on Intel Macs / targeting Intel Macs (flutter/flutter#188835)
2026-07-07 [email protected] Roll Dart SDK from 4c03f64b19f6 to 70577d6f2bba (1 revision) (flutter/flutter#189031)
2026-07-07 [email protected] Roll Fuchsia Linux SDK from n1Lm2Z4DZkfC3bwj5... to 7RjQJBW3m-3Jl-7jr... (flutter/flutter#189032)
2026-07-06 [email protected] Recommend `OverlayPortal.overlayChildLayoutBuilder` over Target-Follower (flutter/flutter#188894)
2026-07-06 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#189025)
2026-07-06 [email protected] Rename preferredSize to size and preferredConstraints to constraints in the windowing API (flutter/flutter#189017)
2026-07-06 [email protected] Skip locked issues in no-response check (flutter/flutter#188950)
2026-07-06 [email protected] Fix potential race condtion in android_semantics_integration_test (flutter/flutter#188830)
2026-07-06 [email protected] ci: udpate wait-for-engine-build composite action to cocoon (flutter/flutter#189020)
2026-07-06 [email protected] Roll Skia from 2b55eed5500d to 7dccd1e79a5b (3 revisions) (flutter/flutter#189021)
2026-07-06 [email protected] [AGP 9] Update Flutter Template Versions (flutter/flutter#188762)
2026-07-06 [email protected] fix(engine/windows): keep tooltip position rect alive - fix use after free (flutter/flutter#188476)
2026-07-06 [email protected] [Tool] Fix null check operator crash in currentPackageConfig (flutter/flutter#188454)
2026-07-06 [email protected] [Tool] Gracefully handle WDAC/AppLocker blocks for impellerc (flutter/flutter#188452)
2026-07-06 [email protected] [flutter_tools] Throw DaemonException if app fails to start early (flutter/flutter#188921)
2026-07-06 [email protected] Roll Dart SDK from ce7a2567eb59 to 4c03f64b19f6 (2 revisions) (flutter/flutter#189015)
2026-07-06 [email protected] [flutter_tools, engine] Add --disable-service-origin-check option to disable VM service origin checks (flutter/flutter#188745)
2026-07-06 [email protected] [flutter_tools] Fix test flakiness in widget_preview_detection_test.dart (flutter/flutter#188922)
2026-07-06 [email protected] Roll pub packages (flutter/flutter#189009)
2026-07-06 [email protected] Roll Skia from c0e2b9667d91 to 2b55eed5500d (1 revision) (flutter/flutter#189006)
2026-07-06 [email protected] Roll Packages from 2fbe873 to fc00ceb (1 revision) (flutter/flutter#189007)
2026-07-06 [email protected] Roll Skia from b68567542f81 to c0e2b9667d91 (1 revision) (flutter/flutter#189004)
2026-07-06 [email protected] Fixing multiline GetBoxesForRange (flutter/flutter#188803)
2026-07-06 [email protected] Roll Skia from e15ea7a4b927 to b68567542f81 (4 revisions) (flutter/flutter#189000)
2026-07-06 [email protected] Roll Skia from 79806692425f to e15ea7a4b927 (2 revisions) (flutter/flutter#188992)
2026-07-06 [email protected] Roll Skia from 2826ae6dc649 to 79806692425f (1 revision) (flutter/flutter#188991)
2026-07-06 [email protected] Roll Skia from 7f99eee20fd6 to 2826ae6dc649 (1 revision) (flutter/flutter#188990)
2026-07-06 [email protected] Add debugPaintFocusBoxes (flutter/flutter#188288)
2026-07-05 [email protected] Roll Fuchsia Linux SDK from bkK6BLiZDRnE7AQQj... to n1Lm2Z4DZkfC3bwj5... (flutter/flutter#188989)
2026-07-05 [email protected] Roll Skia from 75a4bf6706bd to 7f99eee20fd6 (2 revisions) (flutter/flutter#188988)
...
kalyujniy pushed a commit to brickit-app/camera that referenced this pull request Jul 8, 2026
…lutter#12137)

Manual roll Flutter from 6995038d96ef to 91939cc4db78 (48 revisions)

Manual roll requested by [email protected]

flutter/flutter@6995038...91939cc

2026-07-07 [email protected] Roll Skia from 80ae1deed9ed to 075fbe4778d9 (6 revisions) (flutter/flutter#189067)
2026-07-07 [email protected] Bump customer testing version for new registrants (flutter/flutter#189070)
2026-07-07 [email protected] Roll Packages from fc00ceb to 92525f5 (2 revisions) (flutter/flutter#189069)
2026-07-07 [email protected] fix android semantics integration test hangs due to postframe callback (flutter/flutter#189043)
2026-07-07 [email protected] Bump goldctl (flutter/flutter#189030)
2026-07-07 [email protected] Roll Skia from 71db7c06c5fe to 80ae1deed9ed (2 revisions) (flutter/flutter#189060)
2026-07-07 [email protected] Collect analytics on AI agent usage (flutter/flutter#187630)
2026-07-07 [email protected] Roll Skia from 125a76cc4cf3 to 71db7c06c5fe (4 revisions) (flutter/flutter#189054)
2026-07-07 [email protected] Roll Dart SDK from 70577d6f2bba to c648e3429d76 (1 revision) (flutter/flutter#189052)
2026-07-07 [email protected] Fix RenderSliverPadding setter assertion (flutter/flutter#187353)
2026-07-07 [email protected] Roll Skia from 2dde156aec3e to 125a76cc4cf3 (3 revisions) (flutter/flutter#189037)
2026-07-07 [email protected] Explain asynchronous causes in the setState() called after dispose() error (flutter/flutter#187294)
2026-07-07 [email protected] Roll Skia from 7dccd1e79a5b to 2dde156aec3e (2 revisions) (flutter/flutter#189035)
2026-07-07 [email protected] Add `STRING_CATALOG_GENERATE_SYMBOLS = YES;` (flutter/flutter#188163)
2026-07-07 [email protected] Print warnings on Intel Macs / targeting Intel Macs (flutter/flutter#188835)
2026-07-07 [email protected] Roll Dart SDK from 4c03f64b19f6 to 70577d6f2bba (1 revision) (flutter/flutter#189031)
2026-07-07 [email protected] Roll Fuchsia Linux SDK from n1Lm2Z4DZkfC3bwj5... to 7RjQJBW3m-3Jl-7jr... (flutter/flutter#189032)
2026-07-06 [email protected] Recommend `OverlayPortal.overlayChildLayoutBuilder` over Target-Follower (flutter/flutter#188894)
2026-07-06 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#189025)
2026-07-06 [email protected] Rename preferredSize to size and preferredConstraints to constraints in the windowing API (flutter/flutter#189017)
2026-07-06 [email protected] Skip locked issues in no-response check (flutter/flutter#188950)
2026-07-06 [email protected] Fix potential race condtion in android_semantics_integration_test (flutter/flutter#188830)
2026-07-06 [email protected] ci: udpate wait-for-engine-build composite action to cocoon (flutter/flutter#189020)
2026-07-06 [email protected] Roll Skia from 2b55eed5500d to 7dccd1e79a5b (3 revisions) (flutter/flutter#189021)
2026-07-06 [email protected] [AGP 9] Update Flutter Template Versions (flutter/flutter#188762)
2026-07-06 [email protected] fix(engine/windows): keep tooltip position rect alive - fix use after free (flutter/flutter#188476)
2026-07-06 [email protected] [Tool] Fix null check operator crash in currentPackageConfig (flutter/flutter#188454)
2026-07-06 [email protected] [Tool] Gracefully handle WDAC/AppLocker blocks for impellerc (flutter/flutter#188452)
2026-07-06 [email protected] [flutter_tools] Throw DaemonException if app fails to start early (flutter/flutter#188921)
2026-07-06 [email protected] Roll Dart SDK from ce7a2567eb59 to 4c03f64b19f6 (2 revisions) (flutter/flutter#189015)
2026-07-06 [email protected] [flutter_tools, engine] Add --disable-service-origin-check option to disable VM service origin checks (flutter/flutter#188745)
2026-07-06 [email protected] [flutter_tools] Fix test flakiness in widget_preview_detection_test.dart (flutter/flutter#188922)
2026-07-06 [email protected] Roll pub packages (flutter/flutter#189009)
2026-07-06 [email protected] Roll Skia from c0e2b9667d91 to 2b55eed5500d (1 revision) (flutter/flutter#189006)
2026-07-06 [email protected] Roll Packages from 2fbe873 to fc00ceb (1 revision) (flutter/flutter#189007)
2026-07-06 [email protected] Roll Skia from b68567542f81 to c0e2b9667d91 (1 revision) (flutter/flutter#189004)
2026-07-06 [email protected] Fixing multiline GetBoxesForRange (flutter/flutter#188803)
2026-07-06 [email protected] Roll Skia from e15ea7a4b927 to b68567542f81 (4 revisions) (flutter/flutter#189000)
2026-07-06 [email protected] Roll Skia from 79806692425f to e15ea7a4b927 (2 revisions) (flutter/flutter#188992)
2026-07-06 [email protected] Roll Skia from 2826ae6dc649 to 79806692425f (1 revision) (flutter/flutter#188991)
2026-07-06 [email protected] Roll Skia from 7f99eee20fd6 to 2826ae6dc649 (1 revision) (flutter/flutter#188990)
2026-07-06 [email protected] Add debugPaintFocusBoxes (flutter/flutter#188288)
2026-07-05 [email protected] Roll Fuchsia Linux SDK from bkK6BLiZDRnE7AQQj... to n1Lm2Z4DZkfC3bwj5... (flutter/flutter#188989)
2026-07-05 [email protected] Roll Skia from 75a4bf6706bd to 7f99eee20fd6 (2 revisions) (flutter/flutter#188988)
...
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.

RenderSliverPadding.padding setter does not validate incoming negative padding

3 participants