KeyframesTween.fromTime constructor
KeyframesTween.fromTime({
- required List<
TimeKeyframeProperty> properties, - Duration? totalDuration,
Creates a tween from durations instead of a double value.
If totalDuration
isn't defined, the time of the last keyframe is used.
Implementation
factory KeyframesTween.fromTime({
required List<TimeKeyframeProperty> properties,
Duration? totalDuration,
}) {
final Duration total = totalDuration ??
properties.fold(
Duration.zero,
(max, property) {
final Duration propertyMax = property.keyframes.fold(
Duration.zero,
(max, timeframe) =>
max.inMilliseconds < timeframe.time.inMilliseconds
? timeframe.time
: max,
);
return max.inMilliseconds < propertyMax.inMilliseconds
? propertyMax
: max;
},
);
return KeyframesTween([
...properties.map(
(e) => e.toKeyframeProperty(total),
),
]);
}