Expand description
Concrete Simulation curves — the ballistic motion a
ScrollPhysics hands back once a gesture releases.
Four ports of Flutter’s scroll math, formulas and tuning constants carried
over unchanged so a frust fling lands where the platform’s own would:
physics/friction_simulation.dart (FrictionSimulation),
physics/spring_simulation.dart (SpringSimulation,
ScrollSpringSimulation) and widgets/scroll_simulation.dart
(ClampingScrollSimulation, BouncingScrollSimulation) — the last two
being in turn ports of Android’s SplineOverScroller curve and iOS’s
UIScrollView friction-then-rubber-band behavior. Every tuning constant is
stated as the expression its source states it as (never a transcribed
decimal) and pinned by a test in this file.
Time is in seconds from each simulation’s own start, per the
Simulation contract; a simulation carries the Tolerance it settles
within as a constructor argument rather than reading one per call.
Structs§
- Bouncing
Scroll Simulation - iOS’s fling: exponential friction while the position is in range, handing over to a rubber-band spring at whichever edge the fling reaches.
- Clamping
Scroll Simulation - Android’s fling curve — the
SplineOverScrollerdeceleration a clamping scroll surface runs after a release, which decays to a hard stop at a known duration and distance rather than an asymptote. - Friction
Simulation - Exponential drag decay: the iOS-style fling curve, and the friction phase of
BouncingScrollSimulation. - Scroll
Spring Simulation - A
SpringSimulationthat reports exactlyendonce settled, rather than the residual sub-tolerance displacement the closed form still carries. - Spring
Simulation - A damped spring settling from
startontoend, solvingm·ẍ + c·ẋ + k·x = 0on the displacement between them.
Enums§
- Spring
Type - Which closed-form solution a
SpringSimulationresolved to, decided bydamping² − 4·mass·stiffness.