From 7ebb6412a953c1e3f6755c60c54c9e58b8a21130 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Mon, 14 Dec 2015 12:27:50 -0800 Subject: [PATCH] Only set tolerance if simulation is non-null --- packages/flutter/lib/src/widgets/scrollable.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 18c2d2abdc..c8044ef965 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -197,10 +197,13 @@ abstract class ScrollableState extends State { } Simulation _createFlingSimulation(double velocity) { - final double endVelocity = pixelToScrollOffset(kPixelScrollTolerance.velocity); - final double endDistance = pixelToScrollOffset(kPixelScrollTolerance.distance); - return scrollBehavior.createFlingScrollSimulation(scrollOffset, velocity) - ..tolerance = new Tolerance(velocity: endVelocity.abs(), distance: endDistance); + final Simulation simulation = scrollBehavior.createFlingScrollSimulation(scrollOffset, velocity); + if (simulation != null) { + final double endVelocity = pixelToScrollOffset(kPixelScrollTolerance.velocity); + final double endDistance = pixelToScrollOffset(kPixelScrollTolerance.distance); + simulation.tolerance = new Tolerance(velocity: endVelocity.abs(), distance: endDistance); + } + return simulation; } double snapScrollOffset(double value) {