resolveSpring function
SpringConfig
resolveSpring({
- SpringPreset? preset,
- double? stiffness,
- double? damping,
- Duration? duration,
Resolves a spring the way the web driver's resolveSpring does: a preset
supplies the defaults, and either component may be overridden.
duration is this port's own addition and takes precedence over the
absolute scale of everything else: when it is given, the preset and any
stiffness/damping override are read only for the damping ratio they
describe — the character of the spring — and the stiffness that settles in
that time is solved for. So preset: bouncy, duration: 600ms is the bouncy
spring stretched to 600 ms, not a different spring that happens to be slow.
See springForDuration for the clamping at very short durations.
Implementation
SpringConfig resolveSpring({
SpringPreset? preset,
double? stiffness,
double? damping,
Duration? duration,
}) {
final base = (preset ?? SpringPreset.snappy).config;
final tuned = SpringConfig(stiffness ?? base.k, damping ?? base.c);
if (duration == null) return tuned;
return springForDuration(duration, dampingRatio: dampingRatioOf(tuned));
}