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:42:55 +0200
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
GitHub
2020-09-17 15:42:55 +0200
Commit
8db6176723dfcc1bdb8f3615fa0ce9cb244ca4af
8db61767
2 parents
54b926a3
34f4ffb0
Merge pull request #73
Add PointerDeviceKind to VelocityTracker()
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
lib/src/bottom_sheet.dart
lib/src/bottom_sheet.dart
View file @
8db6176
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -300,7 +299,8 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
// Otherwise the calculate the velocity with a VelocityTracker
if
(
_velocityTracker
==
null
)
{
_velocityTracker
=
VelocityTracker
();
final
pointerKind
=
defaultPointerDeviceKind
(
context
);
_velocityTracker
=
VelocityTracker
(
pointerKind
);
_startTime
=
DateTime
.
now
();
}
DragUpdateDetails
dragDetails
;
...
...
@@ -465,3 +465,23 @@ class _CustomBottomSheetLayout extends SingleChildLayoutDelegate {
return
false
;
}
}
// Checks the device input type as per the OS installed in it
// Mobile platforms will be default to `touch` while desktop will do to `mouse`
// Used with 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