Chromium Code Reviews| Index: sky/sdk/lib/widgets/fixed_height_scrollable.dart |
| diff --git a/sky/sdk/lib/widgets/fixed_height_scrollable.dart b/sky/sdk/lib/widgets/fixed_height_scrollable.dart |
| index 81cdb20cc9b8c82926eb107271572e3f1eeee935..42d0c7903c8fae75b68deb5ecdd2f54b90ca64a0 100644 |
| --- a/sky/sdk/lib/widgets/fixed_height_scrollable.dart |
| +++ b/sky/sdk/lib/widgets/fixed_height_scrollable.dart |
| @@ -23,6 +23,7 @@ abstract class FixedHeightScrollable extends Scrollable { |
| /// Subclasses must implement `get itemCount` to tell FixedHeightScrollable |
| /// how many items there are in the list. |
| int get itemCount; |
| + int _previousItemCount; |
| void syncFields(FixedHeightScrollable source) { |
| padding = source.padding; |
| @@ -39,14 +40,7 @@ abstract class FixedHeightScrollable extends Scrollable { |
| _height = newSize.height; |
| scrollBehavior.containerHeight = _height; |
| }); |
| - } |
| - |
| - bool scrollTo(double newScrollOffset) { |
| - if (_height != null && _height > 0.0) { |
| - double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height); |
| - newScrollOffset = math.min(newScrollOffset, maxScrollOffset); |
| - } |
| - return super.scrollTo(newScrollOffset); |
| + _updateScrollOffset(); |
|
eseidel
2015/07/09 20:40:07
Unneeded.
|
| } |
| void _updateContentsHeight() { |
| @@ -56,8 +50,17 @@ abstract class FixedHeightScrollable extends Scrollable { |
| scrollBehavior.contentsHeight = contentsHeight; |
| } |
| + void _updateScrollOffset() { |
| + if (scrollOffset > scrollBehavior.maxScrollOffset) |
| + settleScrollOffset(); |
| + } |
| + |
| Widget buildContent() { |
| - _updateContentsHeight(); |
| + if (itemCount != _previousItemCount) { |
| + _previousItemCount = itemCount; |
| + _updateContentsHeight(); |
| + _updateScrollOffset(); |
| + } |
| var itemShowIndex = 0; |
| var itemShowCount = 0; |