Use case
RenderSliverPadding validates non-negative padding in its constructor, but its padding setter currently re-checks the existing field instead of the incoming value.
Problem
The setter currently does this:
assert(padding.isNonNegative);
That validates the old value, not the new one being assigned.
As a result, this can slip through the setter in debug mode:
final RenderSliverPadding renderSliverPadding = RenderSliverPadding(
padding: EdgeInsets.zero,
);
renderSliverPadding.padding = const EdgeInsets.all(-1.0);
Expected behavior
Assigning negative padding through RenderSliverPadding.padding should fail the same way the constructor does.
Actual behavior
The setter assertion checks the current padding instead of the incoming value, so negative input is not rejected at the setter boundary.
Additional context
I opened a fix here:
The proposed change is just to validate value.isNonNegative and add a regression test.
Use case
RenderSliverPaddingvalidates non-negative padding in its constructor, but itspaddingsetter currently re-checks the existing field instead of the incoming value.Problem
The setter currently does this:
assert(padding.isNonNegative);That validates the old value, not the new one being assigned.
As a result, this can slip through the setter in debug mode:
Expected behavior
Assigning negative padding through
RenderSliverPadding.paddingshould fail the same way the constructor does.Actual behavior
The setter assertion checks the current
paddinginstead of the incomingvalue, so negative input is not rejected at the setter boundary.Additional context
I opened a fix here:
The proposed change is just to validate
value.isNonNegativeand add a regression test.