AnimatedDrawing.svg constructor

AnimatedDrawing.svg(
  1. String assetPath, {
  2. AnimationController? controller,
  3. bool? run,
  4. Duration? duration,
  5. Curve? animationCurve,
  6. VoidCallback? onFinish,
  7. PaintedPathCallback? onPaint,
  8. PathOrder? animationOrder,
  9. double? width,
  10. double? height,
  11. AnimationRange? range,
  12. LineAnimation? lineAnimation = LineAnimation.oneByOne,
  13. bool scaleToViewport = true,
  14. DebugOptions? debug,
})

Parses path data from an SVG asset. In order to use assets in your project specify those in pubspec.yaml:

assets:
  - assets/my_drawing.svg

By default every animation repeats infinitely. For running an animation only once you can use a callback to set run to false after the first animation cycle completed (see field onFinish).

AnimatedDrawing.svg(
  "assets/test.svg",
  run: this.run,
  duration: new Duration(seconds: 3),
  onFinish: () => setState(() {
    this.run  = false;
  }),
)

Implementation

AnimatedDrawing.svg(
  this.assetPath, {
  //Standard
  this.controller,
  //Simplified version
  this.run,
  this.duration,
  this.animationCurve,
  this.onFinish,
  this.onPaint,
  //For both
  this.animationOrder,
  this.width,
  this.height,
  this.range,
  this.lineAnimation = LineAnimation.oneByOne,
  this.scaleToViewport = true,
  this.debug,
})  : paths = [],
      paints = [] {
  assertAnimationParameters();
  assert(assetPath.isNotEmpty);
}