Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom paints #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/abstract_drawing_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ abstract class AbstractAnimatedDrawingState extends State<AnimatedDrawing> {
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();
Expand Down
13 changes: 10 additions & 3 deletions lib/src/drawing_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ class AnimatedDrawing extends StatefulWidget {
this.lineAnimation = LineAnimation.oneByOne,
this.scaleToViewport = true,
this.debug,
}) : this.paths = [],
this.paints = []
this.paints = const <Paint>[],
this.package,

}) : this.paths = []
// this.paints = []
{
assertAnimationParameters();
assert(this.assetPath.isNotEmpty);
Expand Down Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down