Jaime Blasco

Not listen to horizontal scroll updates

@@ -244,17 +244,19 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -244,17 +244,19 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
244 DateTime _startTime; 244 DateTime _startTime;
245 245
246 void _handleScrollUpdate(ScrollNotification notification) { 246 void _handleScrollUpdate(ScrollNotification notification) {
247 -  
248 final scrollPosition = _scrollController.position; 247 final scrollPosition = _scrollController.position;
249 248
  249 + if (scrollPosition.axis == Axis.horizontal) return;
  250 +
  251 + //Check if scrollController is used
  252 + if (!_scrollController.hasClients) return;
  253 +
250 final isScrollReversed = scrollPosition.axisDirection == AxisDirection.down; 254 final isScrollReversed = scrollPosition.axisDirection == AxisDirection.down;
251 final offset = isScrollReversed 255 final offset = isScrollReversed
252 ? scrollPosition.pixels 256 ? scrollPosition.pixels
253 : scrollPosition.maxScrollExtent - scrollPosition.pixels; 257 : scrollPosition.maxScrollExtent - scrollPosition.pixels;
254 258
255 if (offset <= 0) { 259 if (offset <= 0) {
256 - //Check if scrollController is used  
257 - if (!_scrollController.hasClients) return;  
258 // Check if listener is same from scrollController. 260 // Check if listener is same from scrollController.
259 // TODO: Improve the way it checks if it the same view controller 261 // TODO: Improve the way it checks if it the same view controller
260 // Use PrimaryScrollController 262 // Use PrimaryScrollController
@@ -274,9 +276,9 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -274,9 +276,9 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
274 _startTime = null; 276 _startTime = null;
275 return; 277 return;
276 } 278 }
277 - 279 +
278 // Otherwise the calculate the velocity with a VelocityTracker 280 // Otherwise the calculate the velocity with a VelocityTracker
279 - if (_velocityTracker == null) { 281 + if (_velocityTracker == null) {
280 _velocityTracker = VelocityTracker(); 282 _velocityTracker = VelocityTracker();
281 _startTime = DateTime.now(); 283 _startTime = DateTime.now();
282 } 284 }