-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Use RenderSliverPadding to inset SliverFillViewport #45432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use RenderSliverPadding to inset SliverFillViewport #45432
Conversation
| } | ||
|
|
||
| /// A sliver that contains a multiple box children that each fill the viewport. | ||
| /// A sliver that contains a multiple box children that each fills the viewport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// A sliver that contains a multiple box children that each fills the viewport. | |
| /// A sliver that contains multiple box children that each fills the viewport. |
| } | ||
|
|
||
| @override | ||
| EdgeInsetsGeometry get padding { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems odd to override the getter for padding like this. Could this just be a private method that gets called whenever we need to set the padding to obtain the value for the padding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up exposing resolvedPadding instead of markNeedsResolution
e3f3c70 to
c9dab5c
Compare
goderbauer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after comments are resolved.
| /// its child. Any incoming [SliverConstraints.overlap] is ignored and not | ||
| /// passed on to the child. | ||
| /// | ||
| /// Applying padding to anything but the most mundane sliver is likely to have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a macro here since it's the same block of text?
| } | ||
|
|
||
| @override | ||
| EdgeInsets resolvedPadding; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you turn this into a private variable with a public getter to ensure that the value cannot be changed from the outside?
| /// the viewport in the main axis. | ||
| final double viewportFraction; | ||
|
|
||
| /// The delegate that provides the children for this widget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a macro instead of repeating this text from SliverMultiBoxAdaptorWidget?
| } | ||
|
|
||
| assert(false, 'Unreachable'); | ||
| return EdgeInsets.symmetric(vertical: paddingValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return EdgeInsets.zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is no longer necessary because the logic is moved to _resolve. But I wonder what the benefits of returning EdgeInsets.zero are?
| expect(tester.getTopLeft(find.text('Hawaii')), const Offset(-(4 - 1) * 800 / 2, 0)); | ||
| }); | ||
|
|
||
| // Regression test for https://github.com/flutter/flutter/issues/45096. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I believe our style is to make this the first line inside the test body.
|
|
||
| // Regression test for https://github.com/flutter/flutter/issues/45096. | ||
| testWidgets( | ||
| 'PageView large viewportFraction can scroll and to the last page and snap', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: there seems to be an extra "and" in this sentence?
| expect(tester.getCenter(find.text('2')), const Offset(400, 300)); | ||
| }); | ||
|
|
||
| testWidgets( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue that you could mention here for which this is the regression test?
| } | ||
|
|
||
| @override | ||
| EdgeInsets get resolvedPadding { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if its beneficial to performance to cache the value like we do in RenderSliverPadding?
18b763c to
ad7d924
Compare
Description
This PR reimplements
SliverFillViewportin a similar vein to the reverted PR #37024.Related Issues
Fixes #23873
Fixes #27744
Fixes #45096
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?