import 'package:flutter/animation.dart'; /// The quick switch's quintic ease. It always brakes to a stop with zero /// velocity and acceleration. A fresh switch also starts from rest; a switch /// that retargets one already in flight starts at [launch], the slope that /// keeps the incoming chat moving at its current speed instead of stalling. /// /// f(t) = s·t + a·t³ + b·t⁴ + c·t⁵ with f(1) = 1 and f'(1) = f''(1) = 0. /// Slopes above two would overshoot, so [launch] is clamped to [0, 2]. class ChatSwitchEase extends Curve { const ChatSwitchEase([this.launch = 0]); final double launch; @override double transformInternal(double t) { final s = launch.clamp(0.0, 2.0); final a = 10 - 6 * s, b = 8 * s - 15, c = 6 - 3 * s; return t * (s + t * t * (a + t * (b + c * t))); } }