onStart method
This method is called once when the effect is about to start, but before
the first call to apply()
. The notion of "about to start" is defined by
the controller: this method is called when controller.started
property
first becomes true.
If the effect is reset, its onStart()
method will be called again when
the effect is about to start.
Implementation
@override
void onStart() {
_lastOffset = Vector2.zero();
_lastAngle = 0;
final start = _pathMetric.getTangentForOffset(0)!;
if (_followDirection) {
assert(
target is AngleProvider,
'An `oriented` MoveAlongPathEffect cannot be applied to a target that '
'does not support rotation',
);
_lastAngle = -start.angle;
final targetProvider = target;
(targetProvider as AngleProvider).angle = -start.angle;
if (targetProvider is PositionComponent) {
targetProvider.angle += targetProvider.nativeAngle;
}
}
if (_isAbsolute) {
target.position.x = _lastOffset.x = start.position.dx;
target.position.y = _lastOffset.y = start.position.dy;
}
}