trimPath function
Returns the sub-path of path from its start up to fraction t in 0..1,
the Flutter equivalent of SwiftUI's Path.trimmedPath(from:to:).
Implementation
Path trimPath(Path path, double t) {
final clamped = t.clamp(0.0, 1.0);
final out = Path();
for (final metric in path.computeMetrics()) {
out.addPath(metric.extractPath(0, metric.length * clamped), Offset.zero);
}
return out;
}