svg 0.1.0 copy "svg: ^0.1.0" to clipboard
svg: ^0.1.0 copied to clipboard

Dart 1 only

A pure-dart implementation of an SVG parser.

SVG #

Build Status

A pure-dart implementation of an SVG parser. The end goal of this package is to provide a semi-full featured implementation that is able to run in both the browser and on the server (or command line tooling).

Example #

import 'package:svg/svg.path';

void main() {
  // Parses an "up-arrow" shape segment.
  print(parseSvgPath('M0,15,L15,15L7.5,0z'));

  // Outputs:
  // [
  //   SvgPathMoveSegment {x: 0, y: 15, isRelative: false},
  //   SvgPathLineSegment {x: 15, y: 15, isRelative: false}, 
  //   SvgPathLineSegment {x: 7.5, y: 0, isRelative: false}, 
  //   SvgPathClose {}
  // ]
}

Generating Dart code #

Don't want to ship the SVG parser with your client? You can statically analyze SVG files and generate raw Dart code instead!

svgPathToSource('M0,15,L15,15L7.5,0z')

// Outputs
/*
 'const <SvgPathSegment> ['
   'const SvgPathMoveSegment(0, 15), '
   'const SvgPathLineSegment(15, 15), '
   'const SvgPathLineSegment(7.5, 0), '
   'const SvgPathClose()'
 ']'
*/

Currently supported #

  • Parsing a single SVG path that contains move, line, and close commands.
  • Converting a single SVG path to raw Dart (generated) code.
1
likes
15
pub points
68%
popularity

Publisher

unverified uploader

A pure-dart implementation of an SVG parser.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dart_builder, petitparser, quiver

More

Packages that depend on svg