Skip to content

Instantly share code, notes, and snippets.

@smokelaboratory
Created July 28, 2019 15:25
Show Gist options
  • Select an option

  • Save smokelaboratory/c6b67cd37c30f3ad308781d40de0d937 to your computer and use it in GitHub Desktop.

Select an option

Save smokelaboratory/c6b67cd37c30f3ad308781d40de0d937 to your computer and use it in GitHub Desktop.
Bottom Sheet gesture
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