newAnimate method

void newAnimate({
  1. bool? loop,
  2. double? fromX,
  3. double? toX,
  4. double? fromY,
  5. double? toY,
  6. double? fromOpacity,
  7. double? toOpacity,
  8. double? fromRoundedRadius,
  9. double? toRoundedRadius,
  10. double? fromScale,
  11. double? toScale,
  12. double? fromDegrees,
  13. double? toDegrees,
  14. Color? fromColor,
  15. Color? toColor,
  16. Curve? moveXCurve,
  17. Curve? moveYCurve,
  18. Curve? scaleCurve,
  19. Curve? opacityCurve,
  20. Curve? rotateCurve,
  21. Curve? colorChangeCurve,
})

newAnimate for start new animation from last animations value loop for repeat animation fromX, toX, fromY and toY for move toOpacity, fromOpacity for opacity toScale, fromScale for scale fromColor, toColor for color fromRoundedRadius, toRoundedRadius for radius toDegrees, fromDegrees for rotate in a clockwise direction and these animations curves is moveXCurve, moveYCurve, scaleCurve, opacityCurve, rotateCurve and colorChangeCurve enjoy it

Implementation

void newAnimate({
  bool? loop,
  double? fromX,
  double? toX,
  double? fromY,
  double? toY,
  double? fromOpacity,
  double? toOpacity,
  double? fromRoundedRadius,
  double? toRoundedRadius,
  double? fromScale,
  double? toScale,
  double? fromDegrees,
  double? toDegrees,
  Color? fromColor,
  Color? toColor,
  Curve? moveXCurve,
  Curve? moveYCurve,
  Curve? scaleCurve,
  Curve? opacityCurve,
  Curve? rotateCurve,
  Curve? colorChangeCurve,
}) {
  this.loop = loop ?? false;

  // init [moveX]
  moveX = Tween<double>(begin: fromX ?? moveX?.value ?? 0, end: toX ?? 0)
      .animate(moveXCurve == null
          ? _animationController!
          : CurvedAnimation(
              parent: _animationController!,
              curve: moveXCurve,
            ));
  // init [moveY]
  moveY = Tween<double>(begin: fromY ?? moveY?.value ?? 0, end: toY ?? 0)
      .animate(moveXCurve == null
          ? _animationController!
          : CurvedAnimation(
              parent: _animationController!,
              curve: moveXCurve,
            ));
  // init [scale]
  scale =
      Tween<double>(begin: fromScale ?? scale?.value ?? 1, end: toScale ?? 1)
          .animate(scaleCurve == null
              ? _animationController!
              : CurvedAnimation(
                  parent: _animationController!,
                  curve: scaleCurve,
                ));
  // init [rotate]
  rotate = Tween<double>(
          begin: fromDegrees ?? rotate?.value ?? 0, end: toDegrees ?? 0)
      .animate(rotateCurve == null
          ? _animationController!
          : CurvedAnimation(
              parent: _animationController!,
              curve: rotateCurve,
            ));
  // init [color]
  color = ColorTween(
          begin: fromColor ?? color?.value ?? Colors.transparent,
          end: toColor ?? color?.value ?? Colors.transparent)
      .animate(colorChangeCurve == null
          ? _animationController!
          : CurvedAnimation(
              parent: _animationController!,
              curve: colorChangeCurve,
            ));
  // init [opacity]
  opacity = Tween<double>(
          begin: fromOpacity ?? opacity?.value ?? 1, end: toOpacity ?? 1)
      .animate(opacityCurve == null
          ? _animationController!
          : CurvedAnimation(
              parent: _animationController!,
              curve: opacityCurve,
            ));
  // init [radius]
  radius = Tween<double>(
          begin: fromRoundedRadius ?? radius?.value ?? 0,
          end: toRoundedRadius ?? radius?.value ?? 0)
      .animate(_animationController!);
  // init [progress]
  progress =
      Tween<double>(begin: 0.0, end: 1.0).animate(_animationController!);
  // the animation value must be 0
  _animationController!.value = 0;
}