diff --git a/lib/src/abstract_drawing_state.dart b/lib/src/abstract_drawing_state.dart index b4d257e..563ce54 100644 --- a/lib/src/abstract_drawing_state.dart +++ b/lib/src/abstract_drawing_state.dart @@ -285,7 +285,8 @@ abstract class AbstractAnimatedDrawingState extends State { bool svgAssetProvided() => this.widget.assetPath.isNotEmpty; void parseFromSvgAsset(SvgParser parser) { - parser.loadFromFile(this.widget.assetPath).then((_) { + final assetPath = widget.package != null ? 'packages/${widget.package}/${widget.assetPath}' : widget.assetPath; + parser.loadFromFile(assetPath).then((_) { setState(() { //raw paths this.widget.paths.clear(); diff --git a/lib/src/drawing_widget.dart b/lib/src/drawing_widget.dart index 7faa6a4..746f1ef 100644 --- a/lib/src/drawing_widget.dart +++ b/lib/src/drawing_widget.dart @@ -50,8 +50,11 @@ class AnimatedDrawing extends StatefulWidget { this.lineAnimation = LineAnimation.oneByOne, this.scaleToViewport = true, this.debug, - }) : this.paths = [], - this.paints = [] + this.paints = const [], + this.package, + + }) : this.paths = [] + // this.paints = [] { assertAnimationParameters(); assert(this.assetPath.isNotEmpty); @@ -98,13 +101,17 @@ class AnimatedDrawing extends StatefulWidget { this.lineAnimation = LineAnimation.oneByOne, this.scaleToViewport = true, this.debug, - }) : this.assetPath = '' + }) : this.assetPath = '', this.package = null { assertAnimationParameters(); assert(this.paths.isNotEmpty); if (this.paints.isNotEmpty) assert(this.paints.length == this.paths.length); } + /// The name of the package from which the picture is included. See the + /// documentation for the [ExactAssetPicture] class itself for details. + final String package; + /// Provide path data via an SVG asset. /// /// For instance an SVG file named my_svg would be specified as "assets/my_svg.svg". Also see * [Supported SVG specifications](https://github.com/biocarl/drawing_animation#supported-svg-specifications). diff --git a/pubspec.yaml b/pubspec.yaml index ac22d2b..815755e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: drawing_animation description: An dart-only library for gradually painting SVG path objects on canvas (drawing line animation). version: 0.1.4 -repository: https://github.com/biocarl/drawing_animation +repository: https://github.com/RockyLeee/drawing_animation homepage: https://twitter.com/cahaucks environment: - sdk: ">2.0.0 <3.0.0" + sdk: ">=2.6.0 <3.0.0" flutter: ">=0.7.3 <2.0.0" dependencies: