From 7192dbb1c6fa227cbdf68e27a4375cfdccdfef87 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 30 Nov 2015 13:36:10 -0800 Subject: [PATCH] Bottom sheets shouldn't dismiss when flung up --- packages/flutter/lib/src/material/bottom_sheet.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index f42eb12fa1c..9c87c731f70 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -52,12 +52,14 @@ class BottomSheet extends StatelessComponent { performance.progress -= delta / (childHeight ?? delta); } - void _handleDragEnd(Offset velocity, BuildContext context) { + void _handleDragEnd(Offset velocity) { if (_dismissUnderway) return; if (velocity.dy > _kMinFlingVelocity) { - performance.fling(velocity: -velocity.dy / childHeight); - onClosing(); + double flingVelocity = -velocity.dy / childHeight; + performance.fling(velocity: flingVelocity); + if (flingVelocity < 0.0) + onClosing(); } else if (performance.progress < _kCloseProgressThreshold) { performance.fling(velocity: -1.0); onClosing(); @@ -69,7 +71,7 @@ class BottomSheet extends StatelessComponent { Widget build(BuildContext context) { return new GestureDetector( onVerticalDragUpdate: _handleDragUpdate, - onVerticalDragEnd: (Offset velocity) { _handleDragEnd(velocity, context); }, + onVerticalDragEnd: _handleDragEnd, child: new Material( child: builder(context) )