Skip to content

Commit

Permalink
fix group processing for clipPath use
Browse files Browse the repository at this point in the history
  • Loading branch information
dnfield committed Dec 29, 2018
1 parent 5c335cb commit 6f3636c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/src/svg/xml_parsers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,20 @@ List<Path> parseClipPathDefinition(
}
} else if (child.name.local == 'use') {
final String xlinkHref = getHrefAttribute(child);
final DrawableStyleable target = definitions.getDrawable('url($xlinkHref)');
print(target);
if (target is DrawableShape) {
return <Path>[target.path];
} else if (target is DrawableGroup) {
return target.children
.whereType<DrawableShape>()
.map<Path>((DrawableShape d) => d.path)
.toList();
final DrawableStyleable definitionDrawable =
definitions.getDrawable('url($xlinkHref)');
final List<Path> paths = <Path>[];

void extractPathsFromDrawable(Drawable target) {
if (target is DrawableShape) {
paths.add(target.path);
} else if (target is DrawableGroup) {
target.children.forEach(extractPathsFromDrawable);
}
}

extractPathsFromDrawable(definitionDrawable);
return paths;
} else {
print('Unsupported clipPath child ${el.name.local}');
}
Expand Down

0 comments on commit 6f3636c

Please sign in to comment.