Created
July 28, 2019 15:25
-
-
Save smokelaboratory/c6b67cd37c30f3ad308781d40de0d937 to your computer and use it in GitHub Desktop.
Bottom Sheet gesture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void _handleDragUpdate(DragUpdateDetails details) { | |
| if (_dismissUnderway) return; | |
| var change = details.primaryDelta / (_childHeight ?? details.primaryDelta); | |
| if (_isDirectionTop()) | |
| _animationController.value += change; | |
| else | |
| _animationController.value -= change; | |
| } | |
| void _handleDragEnd(DragEndDetails details) { | |
| if (_dismissUnderway) return; | |
| if (details.velocity.pixelsPerSecond.dy > 0 && _isDirectionTop()) return; | |
| if (details.velocity.pixelsPerSecond.dy < 0 && !_isDirectionTop()) return; | |
| if (details.velocity.pixelsPerSecond.dy > 700) { | |
| final double flingVelocity = | |
| -details.velocity.pixelsPerSecond.dy / _childHeight; | |
| if (_animationController.value > 0.0) | |
| _animationController.fling(velocity: flingVelocity); | |
| } else if (_animationController.value < 0.5) { | |
| if (_animationController.value > 0.0) | |
| _animationController.fling(velocity: -1.0); | |
| } else | |
| _animationController.reverse(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment