rubberBandSpring property

SpringDescription rubberBandSpring
final

Spring used to animate overscroll bounce from a stationary release in iOS native style.

Used in createBallisticSimulation depending on the conditions.

Research indicates that iOS employs a distinct decay function when a scrollable area is released in an overscroll and stationary state (zero initial velocity), conforming to an exponential decay model.

Implementation

//
// ## Mathematical derivation
//
// A standard spring-damper system follows the second-order differential equation:
// m*x'' + c*x' + k*x = 0
//
// To force this second-order system to behave like a first-order exponential
// decay x(t) = C * e^(-lambda * t), we configure it as an overdamped spring
// with two explicitly defined roots (r1 and r2) for its characteristic
// equation:
//
// * r1 = -lambda (the primary root driving the visible exponential decay)
// * r2 = -100000 * lambda (an extremely large negative root)
//
// Because r2 is massive and negative, its corresponding term in the exact
// mathematical solution (C2 * e^(r2 * t)) decays to zero almost
// instantaneously. The system movement becomes dominated by r1.
//
// Using Vieta's formulas for the characteristic equation r^2 + (c/m)r + (k/m) = 0:
// * r1 + r2 = -c/m => damping (c) = -(r1 + r2) * m
// * r1 * r2 = k/m  => stiffness (k) = (r1 * r2) * m
static final SpringDescription rubberBandSpring = SpringDescription(
  mass: 1.0,
  stiffness: 1e5 * _rubberBandLambda * _rubberBandLambda,
  damping: (1e5 + 1) * _rubberBandLambda,
);