Skip to content

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Nov 22, 2019

Description

This PR reimplements SliverFillViewport in a similar vein to the reverted PR #37024.

Related Issues

Fixes #23873
Fixes #27744
Fixes #45096

Tests

I added the following tests:

  • All visible pages are able to receive touch events
  • PageView large viewportFraction can scroll to the last page

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Nov 22, 2019
}

/// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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 {
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@goderbauer goderbauer left a 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
Copy link
Member

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;
Copy link
Member

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.
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return EdgeInsets.zero?

Copy link
Contributor Author

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.
Copy link
Member

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',
Copy link
Member

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(
Copy link
Member

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 {
Copy link
Member

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?

@LongCatIsLooong LongCatIsLooong merged commit 37f9c54 into flutter:master Nov 27, 2019
@LongCatIsLooong LongCatIsLooong deleted the sliver-fillviewport-fix branch November 27, 2019 19:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

4 participants