path_parsing 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

path_parsing #

Split from the Flutter path drawing library to create a pure Dart parsing library for SVG paths and code generation (without dependencies on Flutter runtime).

CHANGELOG #

0.1.4 #

  • Fix implementation of _PathOffset's == operator.

0.1.3 #

  • Fix a bug in decompose cubic curve - avoid trying to call toInt() on double.infinity
  • Bump test dependency.

0.1.2 #

  • Fix bug with smooth curve commands
  • Add deep testing

0.1.1 #

  • Fix link to homepage in pubspec, add example

0.1.0 #

  • Initial release, based on the 0.2.4 release of path_drawing

example/main.dart

import 'package:path_parsing/path_parsing.dart';

/// A [PathProxy] that dumps Flutter `Path` commands to the console.
class PathPrinter extends PathProxy {
  @override
  void close() {
    print('Path.close();');
  }

  @override
  void cubicTo(
      double x1, double y1, double x2, double y2, double x3, double y3) {
    print('Path.cubicTo($x1, $y1, $x2, $y2, $x3, $y3);');
  }

  @override
  void lineTo(double x, double y) {
    print('Path.lineTo($x, $y);');
  }

  @override
  void moveTo(double x, double y) {
    print('Path.moveTo($x, $y);');
  }
}

void main() {
  const String pathData =
      'M22.1595 3.80852C19.6789 1.35254 16.3807 -4.80966e-07 12.8727 -4.80966e-07C9.36452 -4.80966e-07 6.06642 1.35254 3.58579 3.80852C1.77297 5.60333 0.53896 7.8599 0.0171889 10.3343C-0.0738999 10.7666 0.206109 11.1901 0.64265 11.2803C1.07908 11.3706 1.50711 11.0934 1.5982 10.661C2.05552 8.49195 3.13775 6.51338 4.72783 4.9391C9.21893 0.492838 16.5262 0.492728 21.0173 4.9391C25.5082 9.38548 25.5082 16.6202 21.0173 21.0667C16.5265 25.5132 9.21893 25.5133 4.72805 21.0669C3.17644 19.5307 2.10538 17.6035 1.63081 15.4937C1.53386 15.0627 1.10252 14.7908 0.66697 14.887C0.231645 14.983 -0.0427272 15.4103 0.0542205 15.8413C0.595668 18.2481 1.81686 20.4461 3.5859 22.1976C6.14623 24.7325 9.50955 26 12.8727 26C16.236 26 19.5991 24.7326 22.1595 22.1976C27.2802 17.1277 27.2802 8.87841 22.1595 3.80852Z';

  writeSvgPathDataToPath(pathData, new PathPrinter());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  path_parsing: ^0.1.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ 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:


import 'package:path_parsing/path_parsing.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
76
Health:
Code health derived from static analysis. [more]
78
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Dec 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

Fix lib/src/path_parsing.dart. (-21.78 points)

Analysis of lib/src/path_parsing.dart reported 49 hints, including:

line 26 col 38: Unnecessary new keyword.

line 27 col 40: Unnecessary new keyword.

line 63 col 7: Unnecessary new keyword.

line 66 col 7: Unnecessary new keyword.

line 68 col 7: Unnecessary new keyword.

Fix lib/src/path_segment_type.dart. (-0.50 points)

Analysis of lib/src/path_segment_type.dart reported 1 hint:

line 82 col 7: Avoid const keyword.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
meta >=1.1.2 <2.0.0 1.1.8
vector_math >=2.0.6 <3.0.0 2.0.8
Dev dependencies
path ^1.5.1
test ^1.3.4