Remove redundant assignment of geometry#151821
Remove redundant assignment of geometry#151821auto-submit[bot] merged 3 commits intoflutter:masterfrom hgraceb:master
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| paintExtent: clampDouble(paintExtent, 0.0, constraints.remainingPaintExtent), | ||
| maxPaintExtent: maxExtent, | ||
| hasVisualOverflow: true, // Conservatively say we do have overflow to avoid complexity. | ||
| ); |
There was a problem hiding this comment.
Note to future archaeologists: This code is redundant because updateGeometry called below also calculates and assigns geometry.
| final SliverConstraints constraints = this.constraints; | ||
| final double maxExtent = this.maxExtent; | ||
| layoutChild(constraints.scrollOffset, maxExtent); |
There was a problem hiding this comment.
Optional: This could really just be simplified without the local variables:
| final SliverConstraints constraints = this.constraints; | |
| final double maxExtent = this.maxExtent; | |
| layoutChild(constraints.scrollOffset, maxExtent); | |
| layoutChild(constraints.scrollOffset, maxExtent); |
| from: 0.0, | ||
| to: maxExtent, | ||
| ); | ||
| final double cacheExtent = calculateCacheOffset(constraints, from: 0.0, to: maxExtent); |
There was a problem hiding this comment.
Could you please leave this as-is to keep the line under 80 chars?
There was a problem hiding this comment.
I changed it. Alouthgh In my opinion, it is most applicable to the second description:
but prefer going over if breaking the line would make it less readable, or if it would make the line less consistent with other nearby lines.
abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObjectWithChildMixin<RenderBox>, RenderSliverHelpers {
// ^ 130 chars
// ......
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
// ......
properties.add(DoubleProperty.lazy('child position', () => childMainAxisPosition(child!)));
// ^ 95 chars
}
}
abstract class RenderSliverScrollingPersistentHeader extends RenderSliverPersistentHeader {
// ^ 91 chars
RenderSliverScrollingPersistentHeader({
super.child,
super.stretchConfiguration,
});
double? _childPosition;
@protected
double updateGeometry() {
double stretchOffset = 0.0;
if (stretchConfiguration != null) {
stretchOffset += constraints.overlap.abs();
}
final double maxExtent = this.maxExtent;
final double paintExtent = maxExtent - constraints.scrollOffset;
final double cacheExtent = calculateCacheOffset(constraints, from: 0.0, to: maxExtent);
// ^ 91 chars
geometry = SliverGeometry(
cacheExtent: cacheExtent,
scrollExtent: maxExtent,
paintOrigin: math.min(constraints.overlap, 0.0),
paintExtent: clampDouble(paintExtent, 0.0, constraints.remainingPaintExtent),
// ^ 83 chars
maxPaintExtent: maxExtent + stretchOffset,
hasVisualOverflow: true, // Conservatively say we do have overflow to avoid complexity.
// ^ 93 chars
);
return stretchOffset > 0 ? 0.0 : math.min(0.0, paintExtent - childExtent);
}
@override
void performLayout() {
layoutChild(constraints.scrollOffset, maxExtent);
_childPosition = updateGeometry();
}
@override
double childMainAxisPosition(RenderBox child) {
assert(child == this.child);
assert(_childPosition != null);
return _childPosition!;
}
}
abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistentHeader {
// ^ 88 chars
// ......
}|
@hgraceb You'll also have to get a test exemption for this change per the bot message above. |
I have handled it now. |
|
test-exempt: removing code |
Piinks
left a comment
There was a problem hiding this comment.
LGTM, thank you for the contribution!
Remove redundant assignment of geometry.
Remove redundant assignment of geometry.
Remove redundant assignment of geometry.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.