calculateVerticalOffset method
double
calculateVerticalOffset(
)
Implementation
@protected
double calculateVerticalOffset() {
if (isRefreshing || isAnimating) {
return distanceFraction * threshold;
}
// If drag hasn't gone past the threshold,
// the position is adjustedDistancePulled.
final adjustedDistancePulled = this.adjustedDistancePulled;
if (adjustedDistancePulled <= threshold) {
return adjustedDistancePulled;
}
// How far beyond the threshold pull has gone,
// as a percentage of the threshold.
final overshootPercent = progress.abs() - 1.0;
// Limit the overshoot to 200%. Linear between 0 and 200.
final linearTension = clampDouble(overshootPercent, 0.0, 2.0);
// Non-linear tension. Increases with linearTension,
// but at a decreasing rate.
final tensionPercent =
linearTension - (linearTension * linearTension) / 4.0;
// The additional offset beyond the threshold.
final extraOffset = threshold * tensionPercent;
return threshold + extraOffset;
}