tween method

GTween tween({
  1. required double duration,
  2. Object? x,
  3. Object? y,
  4. Object? scaleX,
  5. Object? scaleY,
  6. Object? scale,
  7. Object? rotation,
  8. Object? rotationX,
  9. Object? rotationY,
  10. Object? pivotX,
  11. Object? pivotY,
  12. Object? width,
  13. Object? height,
  14. Object? skewX,
  15. Object? skewY,
  16. Color? colorize,
  17. Object? alpha,
  18. EaseFunction? ease,
  19. double? delay,
  20. bool? useFrames,
  21. int overwrite = 1,
  22. Function? onStart,
  23. Object? onStartParams,
  24. Function? onComplete,
  25. Object? onCompleteParams,
  26. Function? onUpdate,
  27. Object? onUpdateParams,
  28. bool? runBackwards,
  29. bool? immediateRender,
  30. Map? startAt,
})

Creates a GTween animation for the given properties and returns it.

The duration parameter specifies the length of the tween animation, and the remaining parameters specify the properties to tween (in seconds double or frames int).

The ease parameter can be used to specify an easing function to use for the tween animation. Use GEase

The delay parameter can be used to delay the start of the tween animation (in seconds double or frames int).

The useFrames parameter can be set to true to use frames instead of seconds for the tween animation.

The overwrite parameter specifies the mode of tweening when the GTween animation already exists: 0 = no overwrite. 1 = overwrite all properties.

The onStart, onStartParams, onComplete, onCompleteParams, onUpdate, and onUpdateParams parameters can be used to specify functions to call at various stages of the tween animation.

The runBackwards parameter can be set to true to run the tween animation backwards.

The startAt parameter can be used to specify the initial values of the tween animation properties.

Implementation

GTween tween({
  required double duration,
  Object? x,
  Object? y,
  Object? scaleX,
  Object? scaleY,
  Object? scale,
  Object? rotation,
  Object? rotationX,
  Object? rotationY,
  Object? pivotX,
  Object? pivotY,
  Object? width,
  Object? height,
  Object? skewX,
  Object? skewY,
  Color? colorize,
  Object? alpha,
  EaseFunction? ease,
  double? delay,
  bool? useFrames,
  int overwrite = 1,
  Function? onStart,
  Object? onStartParams,
  Function? onComplete,
  Object? onCompleteParams,
  Function? onUpdate,
  Object? onUpdateParams,
  bool? runBackwards,
  bool? immediateRender,
  Map? startAt,
}) {
  final targetValues = {
    if (x != null) 'x': x,
    if (y != null) 'y': y,
    if (scaleX != null) 'scaleX': scaleX,
    if (scaleY != null) 'scaleY': scaleY,
    if (scale != null) 'scale': scale,
    if (rotation != null) 'rotation': rotation,
    if (rotationX != null) 'rotationX': rotationX,
    if (rotationY != null) 'rotationY': rotationY,
    if (pivotX != null) 'pivotX': pivotX,
    if (pivotY != null) 'pivotY': pivotY,
    if (width != null) 'width': width,
    if (height != null) 'height': height,
    if (skewX != null) 'skewX': skewX,
    if (skewY != null) 'skewY': skewY,
    if (alpha != null) 'alpha': alpha,
    if (colorize != null) 'colorize': colorize,
  };

  return GTween.to(
    this,
    duration,
    targetValues,
    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,
    ),
  );
}