tween method

GTween tween({
  1. required double duration,
  2. Object? x,
  3. Object? y,
  4. GPoint? to,
  5. EaseFunction? ease,
  6. double? delay,
  7. bool? useFrames,
  8. int? overwrite,
  9. VoidCallback? onStart,
  10. Object? onStartParams,
  11. VoidCallback? onComplete,
  12. Object? onCompleteParams,
  13. VoidCallback? onUpdate,
  14. Object? onUpdateParams,
  15. bool? runBackwards,
  16. bool? immediateRender,
  17. Map? startAt,
})

Creates a GTween animation for this object.

The animation can target the 'x' and 'y' properties. You can pass the values for the properties either as separate x and y arguments, or as a single GPoint object in the to argument. You can also specify the duration, easing function, delay, and other parameters for the animation.

If you pass values for both x and y arguments and the to argument, an exception will be thrown. Choose one method to set the values.

Returns the created GTween object.

Implementation

GTween tween({
  required double duration,
  Object? x,
  Object? y,
  GPoint? to,
  EaseFunction? ease,
  double? delay,
  bool? useFrames,
  int? overwrite,
  VoidCallback? onStart,
  Object? onStartParams,
  VoidCallback? onComplete,
  Object? onCompleteParams,
  VoidCallback? onUpdate,
  Object? onUpdateParams,
  bool? runBackwards,
  bool? immediateRender,
  Map? startAt,
}) {
  if ((x != null || y != null) && to != null) {
    throw '''
GTween Can't use 'x, y' AND 'to' arguments for GxPoint tween. Choose one''';
  }
  x = to?.x ?? x;
  y = to?.y ?? y;
  final targetMap = {
    if (x != null) 'x': x,
    if (y != null) 'y': y,
  };
  return GTween.to(
    this,
    duration,
    targetMap,
    GVars(
      ease: ease,
      delay: delay,
      useFrames: useFrames,
      overwrite: overwrite,
      onStart: onStart,
      onStartParams: onStartParams,
      onComplete: onComplete,
      onCompleteParams: onCompleteParams,
      onUpdate: onUpdate,
      onUpdateParams: onUpdateParams,
      runBackwards: runBackwards,
      immediateRender: immediateRender,
      startAt: startAt,
    ),
  );
}