Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
modal_bottom_sheet
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jaime Blasco
2020-09-17 15:36:14 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8b4d3da86f359d2cdfdb05dbd2aa0e2be2bd7e7a
8b4d3da8
1 parent
da6d5251
User targetPlatform to detect PointerDeviceKind
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
lib/src/bottom_sheet.dart
lib/src/bottom_sheet.dart
View file @
8b4d3da
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -301,15 +300,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
// Otherwise the calculate the velocity with a VelocityTracker
if
(
_velocityTracker
==
null
)
{
// Checking the device type as per the OS installed in it
_velocityTracker
=
VelocityTracker
(
// SmartPhone Devices
(
Platform
.
isAndroid
||
Platform
.
isIOS
)
?
PointerDeviceKind
.
touch
:
// PCs or desktops or Laptops devices has mouse pointers
(
Platform
.
isLinux
||
Platform
.
isWindows
||
Platform
.
isMacOS
)
?
PointerDeviceKind
.
mouse
:
// Some unknown devices
PointerDeviceKind
.
unknown
);
final
pointerKind
=
defaultPointerDeviceKind
(
context
);
_velocityTracker
=
VelocityTracker
(
pointerKind
);
_startTime
=
DateTime
.
now
();
}
DragUpdateDetails
dragDetails
;
...
...
@@ -474,3 +466,21 @@ class _CustomBottomSheetLayout extends SingleChildLayoutDelegate {
return
false
;
}
}
// Used by VelocityTracker
// https://github.com/flutter/flutter/pull/64267#issuecomment-694196304
PointerDeviceKind
defaultPointerDeviceKind
(
BuildContext
context
)
{
final
platform
=
Theme
.
of
(
context
)?.
platform
??
defaultTargetPlatform
;
switch
(
platform
)
{
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
android
:
return
PointerDeviceKind
.
touch
;
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
return
PointerDeviceKind
.
mouse
;
case
TargetPlatform
.
fuchsia
:
return
PointerDeviceKind
.
unknown
;
}
return
PointerDeviceKind
.
unknown
;
}
...
...
Please
register
or
login
to post a comment