提交 50d089eb 编写于 作者: H Hixie

Remove redundant setState() calls around scroll behaviour updates.

We don't need to rebuild when those change; we only got the change because we rebuilt in the first place.

R=jackson@google.com

Review URL: https://codereview.chromium.org/1234863004 .
上级 eaf7228f
......@@ -85,6 +85,9 @@ abstract class FixedHeightScrollable extends Scrollable {
List<Widget> items = buildItems(itemShowIndex, itemShowCount);
assert(items.every((item) => item.key != null));
// TODO(ianh): Refactor this so that it does the building in the
// same frame as the size observing, similar to BlockViewport, but
// keeping the fixed-height optimisations.
return new SizeObserver(
callback: _handleSizeChanged,
child: new Viewport(
......
......@@ -23,16 +23,12 @@ class ScrollableViewport extends Scrollable {
double _viewportHeight = 0.0;
double _childHeight = 0.0;
void _handleViewportSizeChanged(Size newSize) {
setState(() {
_viewportHeight = newSize.height;
_updateScrollBehaviour();
});
_viewportHeight = newSize.height;
_updateScrollBehaviour();
}
void _handleChildSizeChanged(Size newSize) {
setState(() {
_childHeight = newSize.height;
_updateScrollBehaviour();
});
_childHeight = newSize.height;
_updateScrollBehaviour();
}
void _updateScrollBehaviour() {
scrollBehavior.contentsSize = _childHeight;
......
......@@ -30,16 +30,15 @@ class VariableHeightScrollable extends Scrollable {
OverscrollBehavior get scrollBehavior => super.scrollBehavior;
void _handleSizeChanged(Size newSize) {
setState(() {
scrollBehavior.containerSize = newSize.height;
});
scrollBehavior.containerSize = newSize.height;
}
void _handleLayoutChanged(
int firstVisibleChildIndex,
int visibleChildCount,
UnmodifiableListView<double> childOffsets,
bool didReachLastChild) {
int firstVisibleChildIndex,
int visibleChildCount,
UnmodifiableListView<double> childOffsets,
bool didReachLastChild
) {
assert(childOffsets.length > 0);
scrollBehavior.contentsSize = didReachLastChild ? childOffsets.last : double.INFINITY;
if (didReachLastChild && scrollOffset > scrollBehavior.maxScrollOffset)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册