Low level toolkit for SVG paths transformations. Sometime you can't use
transformattributes and have to apply changes to svg paths directly. Then this package is for you :) !
This package works both in browser and on server.
new SvgPath(path) #
Constructor. Creates new
SvgPath class instance.
Converts all path commands to absolute.
Converts all path commands to relative. Useful to reduce output size.
.scale(sx [, sy]) #
Rescale path (the same as SVG
sx by default.
.translate(x [, y]) #
Translate path (the same as SVG
y = 0 by default.
.rotate(angle [, rx, ry]) #
Rotate path to
angle degrees around (rx, ry) point. If rotation center not set,
(0, 0) used. The same as SVG
Skew path along the X axis by
Skew path along the Y axis by
.matrix([ m1, m2, m3, m4, m5, m6 ]) #
Apply 2x3 affine transform matrix to path. Params - array. The same as SVG
Any SVG transform or their combination. For example
The same format, as described in SVG standard for
Converts smooth curves
s with "missed" control point to
generic curves (
Replaces all arcs with bezier curves.
.toString() -> String #
Returns final path string.
Round all coordinates to given decimal precision. By default round to integer. Useful to reduce resulting output string size.
.iterate(function(segment, index, x, y) [, keepLazyStack]) #
Apply iterator to all path segments.
- Each iterator receives
yparams. Where (x, y) - absolute coordinates of segment start point.
- Iterator can modify current segment directly (return nothing in this case).
- Iterator can return array of new segments to replace current one (
means that current segment should be deleted).
If second param
keepLazyStack set to
true, then iterator will not evaluate
stacked transforms prior to run. That can be useful to optimize calculations.
- Fix matrix value helper function.
- Implement BoundingBox
- Initial version
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: svgpath: ^1.1.0
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.8.4
- pana: 0.13.13
Health issues and suggestions
Document public APIs. (-0.02 points)
57 out of 59 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.
lib/src/svgpath.dart. (-6.31 points)
lib/src/svgpath.dart reported 13 hints, including:
line 86 col 25: Unnecessary new keyword.
line 163 col 13: Unnecessary new keyword.
line 197 col 13: Unnecessary new keyword.
line 206 col 16: Unnecessary new keyword.
line 212 col 26: Don't explicitly initialize variables to null.
lib/src/path_parse.dart. (-2.48 points)
lib/src/path_parse.dart reported 5 hints:
line 4 col 22: Avoid const keyword.
line 18 col 17: Avoid const keyword.
line 314 col 15: Unnecessary new keyword.
line 324 col 9: Use contains instead of indexOf
line 332 col 10: Unnecessary new keyword.
lib/src/transform_parse.dart. (-1.99 points)
lib/src/transform_parse.dart reported 4 hints:
line 6 col 20: Avoid const keyword.
line 19 col 16: Unnecessary new keyword.
line 24 col 36: Unnecessary new keyword.
line 38 col 25: Unnecessary new keyword.
lib/src/matrix.dart. (-0.50 points)
lib/src/matrix.dart reported 1 hint:
line 106 col 48: Use
= to separate a named parameter from its default value.
dartfmt to format
Package is getting outdated. (-37.26 points)
The package was last published 71 weeks ago.
The package description is too short. (-18 points)
Add more detail to the
description field of
pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
svgpath.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.