From 03e893927fb63b84f668ead87e959458a035f55f Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Wed, 9 Dec 2015 15:42:41 -0800 Subject: [PATCH] Fix PageableList demo --- .../flutter/lib/src/widgets/pageable_list.dart | 14 +++++++++++--- packages/flutter/lib/src/widgets/scrollable.dart | 12 ------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/packages/flutter/lib/src/widgets/pageable_list.dart b/packages/flutter/lib/src/widgets/pageable_list.dart index aa8f38b8604..7a27da4d2f7 100644 --- a/packages/flutter/lib/src/widgets/pageable_list.dart +++ b/packages/flutter/lib/src/widgets/pageable_list.dart @@ -131,11 +131,19 @@ class PageableListState> extends ScrollableSta ); } - ScrollBehavior createScrollBehavior() { - return config.itemsWrap ? new UnboundedBehavior() : new OverscrollBehavior(); + UnboundedBehavior _unboundedBehavior; + OverscrollBehavior _overscrollBehavior; + + ExtentScrollBehavior get scrollBehavior { + if (config.itemsWrap) { + _unboundedBehavior ??= new UnboundedBehavior(); + return _unboundedBehavior; + } + _overscrollBehavior ??= new OverscrollBehavior(); + return _overscrollBehavior; } - ExtentScrollBehavior get scrollBehavior => super.scrollBehavior; + ScrollBehavior createScrollBehavior() => scrollBehavior; bool get snapScrollOffsetChanges => config.itemsSnapAlignment == ItemsSnapAlignment.item; diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index bc2d960ba99..51251a768e7 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -197,18 +197,6 @@ abstract class ScrollableState extends State { } Simulation _createFlingSimulation(double velocity) { - /* - // Assume that we're rendering at atleast 15 FPS. Stop when we're - // scrolling less than one logical pixel per frame. We're essentially - // normalizing by the devicePixelRatio so that the threshold has the - // same effect independent of the device's pixel density. - double endVelocity = pixelToScrollOffset(15.0 * ui.window.devicePixelRatio); - - // Similar to endVelocity. Stop scrolling when we're this close to - // destiniation scroll offset. - double endDistance = pixelToScrollOffset(0.5 * ui.window.devicePixelRatio); - */ - final double endVelocity = pixelToScrollOffset(kPixelScrollTolerance.velocity); final double endDistance = pixelToScrollOffset(kPixelScrollTolerance.distance); return scrollBehavior.createFlingScrollSimulation(scrollOffset, velocity)