Jaime Blasco
@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 -  
7 import 'package:flutter/cupertino.dart'; 6 import 'package:flutter/cupertino.dart';
8 import 'package:flutter/foundation.dart'; 7 import 'package:flutter/foundation.dart';
9 import 'package:flutter/gestures.dart'; 8 import 'package:flutter/gestures.dart';
@@ -300,7 +299,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -300,7 +299,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
300 299
301 // Otherwise the calculate the velocity with a VelocityTracker 300 // Otherwise the calculate the velocity with a VelocityTracker
302 if (_velocityTracker == null) { 301 if (_velocityTracker == null) {
303 - _velocityTracker = VelocityTracker(); 302 + final pointerKind = defaultPointerDeviceKind(context);
  303 + _velocityTracker = VelocityTracker(pointerKind);
304 _startTime = DateTime.now(); 304 _startTime = DateTime.now();
305 } 305 }
306 DragUpdateDetails dragDetails; 306 DragUpdateDetails dragDetails;
@@ -465,3 +465,23 @@ class _CustomBottomSheetLayout extends SingleChildLayoutDelegate { @@ -465,3 +465,23 @@ class _CustomBottomSheetLayout extends SingleChildLayoutDelegate {
465 return false; 465 return false;
466 } 466 }
467 } 467 }
  468 +
  469 +// Checks the device input type as per the OS installed in it
  470 +// Mobile platforms will be default to `touch` while desktop will do to `mouse`
  471 +// Used with VelocityTracker
  472 +// https://github.com/flutter/flutter/pull/64267#issuecomment-694196304
  473 +PointerDeviceKind defaultPointerDeviceKind(BuildContext context) {
  474 + final platform = Theme.of(context)?.platform ?? defaultTargetPlatform;
  475 + switch (platform) {
  476 + case TargetPlatform.iOS:
  477 + case TargetPlatform.android:
  478 + return PointerDeviceKind.touch;
  479 + case TargetPlatform.linux:
  480 + case TargetPlatform.macOS:
  481 + case TargetPlatform.windows:
  482 + return PointerDeviceKind.mouse;
  483 + case TargetPlatform.fuchsia:
  484 + return PointerDeviceKind.unknown;
  485 + }
  486 + return PointerDeviceKind.unknown;
  487 +}