endDrag method
End the drag and snap based on velocityPxPerSecond.
Implementation
void endDrag(double velocityPxPerSecond, double availableHeight) {
if (!_state.isDragging) return;
final current = _animationController.value;
// Velocity threshold in normalized units/s
final normVelocity = availableHeight > 0
? -velocityPxPerSecond / availableHeight
: 0.0;
bool shouldExpand;
const velocityThreshold = 1.5; // normalized
const progressThreshold = 0.5;
if (normVelocity.abs() > velocityThreshold) {
shouldExpand = normVelocity > 0;
} else {
shouldExpand = current >= progressThreshold;
}
if (shouldExpand) {
expandFrom();
} else {
collapse();
}
}