build method
Widget
build(
- BuildContext context,
- Widget child,
- AnimationController controller,
- EffectEntry entry,
override
Builds the widgets that implement the effect on the target child
,
based on the provided AnimationController and EffectEntry.
Implementation
@override
Widget build(
BuildContext context,
Widget child,
AnimationController controller,
EffectEntry entry,
) {
Animation<double> animation = buildAnimation(controller, entry);
List<PathMetric> metrics = path.computeMetrics().toList();
if (metrics.isEmpty) return child;
PathMetric metric = metrics.first;
return getOptimizedBuilder<double>(
animation: animation,
builder: (_, __) {
Tangent? tangent =
metric.getTangentForOffset(metric.length * animation.value);
Offset position = tangent?.position ?? Offset.zero;
double rotation = rotate ? -(tangent?.angle ?? 0) + rotationOffset : 0;
Matrix4 mtx = getMatrix(position.dx, position.dy, rotation);
return Transform(
transform: mtx,
transformHitTests: transformHitTests,
alignment: Alignment.center,
child: child,
);
},
);
}