Showing
1 changed file
with
14 additions
and
8 deletions
| @@ -69,6 +69,8 @@ class ModalBottomSheet extends StatefulWidget { | @@ -69,6 +69,8 @@ class ModalBottomSheet extends StatefulWidget { | ||
| 69 | /// the top bound. | 69 | /// the top bound. |
| 70 | final bool bounce; | 70 | final bool bounce; |
| 71 | 71 | ||
| 72 | + // Force the widget to fill the maximum size of the viewport | ||
| 73 | + // or if false it will fit to the content of the widget | ||
| 72 | final bool expanded; | 74 | final bool expanded; |
| 73 | 75 | ||
| 74 | final WidgetWithChildBuilder containerBuilder; | 76 | final WidgetWithChildBuilder containerBuilder; |
| @@ -242,22 +244,26 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | @@ -242,22 +244,26 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> | ||
| 242 | DateTime _startTime; | 244 | DateTime _startTime; |
| 243 | 245 | ||
| 244 | void _handleScrollUpdate(ScrollNotification notification) { | 246 | void _handleScrollUpdate(ScrollNotification notification) { |
| 245 | - double diff = _scrollController.position.axisDirection == AxisDirection.down | ||
| 246 | - ? _scrollController.position.pixels | ||
| 247 | - : _scrollController.position.maxScrollExtent - | ||
| 248 | - _scrollController.position.pixels; | 247 | + final scrollPosition = _scrollController.position; |
| 248 | + | ||
| 249 | + final isScrollReversed = scrollPosition.axisDirection == AxisDirection.down; | ||
| 250 | + final diff = isScrollReversed | ||
| 251 | + ? scrollPosition.pixels | ||
| 252 | + : scrollPosition.maxScrollExtent - scrollPosition.pixels; | ||
| 253 | + | ||
| 249 | if (diff <= 0) { | 254 | if (diff <= 0) { |
| 250 | - //Check if listener is same from scrollController | 255 | + //Check if scrollController is used |
| 251 | if (!_scrollController.hasClients) return; | 256 | if (!_scrollController.hasClients) return; |
| 252 | - | ||
| 253 | - if (_scrollController.position.pixels != notification.metrics.pixels) { | 257 | + //Check if listener is same from scrollController |
| 258 | + if (scrollPosition.pixels != notification.metrics.pixels) { | ||
| 254 | return; | 259 | return; |
| 255 | } | 260 | } |
| 256 | - DragUpdateDetails dragDetails; | 261 | + |
| 257 | if (notification is ScrollStartNotification) { | 262 | if (notification is ScrollStartNotification) { |
| 258 | _velocityTracker = VelocityTracker(); | 263 | _velocityTracker = VelocityTracker(); |
| 259 | _startTime = DateTime.now(); | 264 | _startTime = DateTime.now(); |
| 260 | } | 265 | } |
| 266 | + DragUpdateDetails dragDetails; | ||
| 261 | if (notification is ScrollUpdateNotification) { | 267 | if (notification is ScrollUpdateNotification) { |
| 262 | dragDetails = notification.dragDetails; | 268 | dragDetails = notification.dragDetails; |
| 263 | } | 269 | } |
-
Please register or login to post a comment