Viewing version 1.3.2. Open the latest package page.

vector_graphics_compiler

1.3.2

A compiler to convert SVGs to the binary format used by `package:vector_graphics`.

Download archive

Readme

vector_graphics_compiler

A compiler for package:vector_graphics.

This package parses SVG files into a format that the vector_graphics runtime can render.

Features

Supported SVG features:

  • Groups, paths, and basic shapes are all supported.
  • References, including out of order references.
  • Linear and radial gradients, including radial gradients with focal points.
  • Text
  • Symbols
  • Images
  • Patterns

Unsupported SVG features:

  • Filters
  • Some text processing attributes

Optimizations:

  • Opacity peepholing
  • Transformation inlining (except for text and radial gradients)
  • Group collapsing
  • Mask and clip elimination

Commemoration

This package was originally authored by Dan Field and has been forked here from dnfield/vector_graphics. Dan was a member of the Flutter team at Google from 2018 until his death in 2024. Dan’s impact and contributions to Flutter were immeasurable, and we honor his memory by continuing to publish and maintain this package.

Changelog

1.3.2

  • Fixes a tspan without its own position being drawn with its parent group transform applied twice.

1.3.1

  • Adds support for SVG alpha masks (mask-type="alpha").
  • Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.

1.3.0

  • An unrecognized font-weight value is now ignored with a warning (and still throws when warningsAsErrors is set) instead of always throwing. This preserves an inherited weight, or the initial normal weight at the root, and lets the compiler tolerate non-standard values such as regular emitted by some SVG generators.

1.2.6

  • Fixes linux-arm64 host support by selecting the Flutter engine artifact directory from Abi.current() instead of a hardcoded linux-x64.

1.2.5

  • Updates allowed version range of xml to include up to 7.0.1.

1.2.4

  • Fix Stack Overflow crashes caused by circular references (masks, patterns, deferred nodes, and clip paths).
  • Prevent CPU/Memory Denial of Service (DoS) resource exhaustion from exponential DAG reference expansions (Billion Laughs SVG exploits) by enforcing a strict, cumulative reference expansion safety limit of 1,000.
  • Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

1.2.3

  • Fixes the SVG parser injecting a spurious space between adjacent <tspan> elements that have no whitespace between them in the source. Previously <tspan>A</tspan><tspan>B</tspan> was emitted as "A" + " B", producing a visible gap; it now emits "A" + "B" to match every browser.

1.2.2

  • Adds support for modern space-separated HSL and HSLA color syntax.

1.2.1

  • Fixes HSL/HSLA color parsing for decimal percentage components (e.g. hsl(270, 100%, 76.27%)).

1.2.0

  • Adds support for percentage units in SVG shape attributes (rect, circle, ellipse, line).

1.1.20

  • Fixes color parsing for modern rgb and rgba CSS syntax.
  • Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.

1.1.19

  • Updates allowed version range of xml to include up to 6.6.1.
  • Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

1.1.18

  • Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
  • Fixes SVG matrix parsing to explicitly set the Z scale value.

1.1.17

  • Fixes a bug where stroke opacity not applied by color mapper.

1.1.16

  • Sets stroke-width to 1 by default when an invalid value is parsed instead of throwing an exception.

1.1.15

  • Fixes a bug where empty tags caused the parser to crash.

1.1.14

  • Makes the package WASM compatible.

1.1.13

  • Relaxes dependency constraint on vector_graphics_codec.

1.1.12

1.1.11+1

  • Relax package:http constraint.

1.1.11

  • Use package:http to drop dependency on dart:html.

1.1.10+1

  • Add missing save before clip.

1.1.10

  • Add missing clip before saveLayer.

1.1.9+2

  • Fix case sensitivity on scientific notation parsing.

1.1.9+1

  • Fix publication error that did not have latest source code.

1.1.9

  • Fix handling of invalid XML @id attributes.
  • Fix handling of self-referential <use/> elements.
  • Add --out-dir option to compiler.
  • Tweak warning message for unhandled eleemnts.

1.1.8

  • Fix bugs in transform parsing.

1.1.7

  • Support for matching the ambient text direction.

1.1.6

  • Fix bug in text position computation when transforms are involved.

1.1.5+1

  • Remove/update some invalid assertions related to image formats.

1.1.5

  • Support for encoding path control points as IEEE 754-2008 half precision floating point values using the option --use-half-precision-control-points.
  • Added an error builder property to provide a fallback widget on exceptions.

1.1.4

  • Support more image formats and malformed MIME types.
  • Fix inheritence for fill-rules.

1.1.3

  • Further improvements to whitespace handling for text.

1.1.2

  • Fix handling and inheritence of none.

1.1.1

  • Multiple text positioning bug fixes.
  • Preserve stroke-opacity when specified.

1.1.0

  • Fix a number of inheritence related bugs:
    • Inheritence of properties specified on the root element now work.
    • Opacity inheritence is more correct now.
    • Inheritence of use elements is more correctly handled.
  • Make currentColor non-null on SVG theme, and fix how it is applied.
  • Remove the opacity peephole optimizer, which was incorrectly applying optimizations in a few cases. A future release may add this back.
  • Add clipBehavior to the widget.
  • Fix patterns when multiple patterns are specified and applied within the graphic.

1.0.1

  • Fix handling of unspecified fill colors on use/group elements.

1.0.0+1

  • Fix issue in pattern decoding.
  • Fix issue in matrix parsing for some combinations of matrices.

1.0.0

  • Initial stable release.
  • Parsing is now synchronous, and is easier to work with in tests.
  • Correctly handle images with ids and defined in defs blocks.
  • Compile time color remapping support.

0.0.3

  • Better concurrency support
  • Pattern support.
  • Bug fixes around image handling.
  • Bug fix for when optimizers are used on non-default fill types.
  • Support for SVG theme related properties (currentColor, font-size, x-height).

0.0.2

  • Add optimizations for masks, clipping, and overdraw.

0.0.1

  • Create repository

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'vector_graphics_compiler:1.3.2'
pubspec.yaml
name: vector_graphics_compiler
description: A compiler to convert SVGs to the binary format used by `package:vector_graphics`.
repository: https://github.com/flutter/packages/tree/main/packages/vector_graphics_compiler
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+vector_graphics%22
version: 1.3.2

executables:
  vector_graphics_compiler:

environment:
  sdk: ^3.11.0

dependencies:
  args: ^2.3.0
  meta: ^1.7.0
  path: ^1.8.0
  path_parsing: ^1.0.1
  vector_graphics_codec: ^1.1.11+1
  # This uses an exact upper range because it is an external dependency (see
  # https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#dependencies
  # for more information), and this mitigates transitive risk exposure to
  # clients. To update this value:
  # - Audit the package's source diffs between the current max version listed
  #   here and the target version.
  # - Update the max version here to exactly the audited version.
  xml: ">=6.3.0 <=7.0.1"

dev_dependencies:
  flutter:
    sdk: flutter
  flutter_test:
    sdk: flutter
  test: ^1.20.1
  vector_graphics: ^1.1.13
  vector_math: ^2.1.2

platforms:
  android:
  ios:
  linux:
  macos:
  web:
  windows:

topics:
  - svg
  - vector-graphics

Version history

VersionPublishedArchiveSHA-256
0.0.0Cached · Upstream SHA-256 matchedDownload70349fb1…4b54cf
0.0.1Cached · Upstream SHA-256 matchedDownload522c2bed…5cefb4
0.0.2On demandDownload24596228…568688
0.0.3Cached · Upstream SHA-256 matchedDownloada7ce5a10…02d467
0.0.4Cached · Upstream SHA-256 matchedDownloadfc9528ce…971163
0.0.5Cached · Upstream SHA-256 matchedDownload74582743…e75740
1.0.0Cached · Upstream SHA-256 matchedDownload7863ea5f…72362f
1.0.0+1Cached · Upstream SHA-256 matchedDownload009c3321…8b64a2
1.0.1Cached · Upstream SHA-256 matchedDownload5d9010c4…10d24e
1.1.0Cached · Upstream SHA-256 matchedDownload3190cc26…daff86
1.1.1Cached · Upstream SHA-256 matchedDownload9e8066d2…a10b3e
1.1.2Cached · Upstream SHA-256 matchedDownload464d3e46…38db06
1.1.3Cached · Upstream SHA-256 matchedDownload524c9889…c2bec3
1.1.4Cached · Upstream SHA-256 matchedDownload0bf61ad5…9d6163
1.1.5Cached · Upstream SHA-256 matchedDownload15edc42f…97c4ca
1.1.5+1Cached · Upstream SHA-256 matchedDownload6ca1298b…1c61bb
1.1.6Cached · Upstream SHA-256 matchedDownload7430f5d8…b28e5b
1.1.7Cached · Upstream SHA-256 matchedDownload80a13c61…03ba2e
1.1.9Cached · Upstream SHA-256 matchedDownloadd26c0e2f…5dc47f
1.1.9+1Cached · Upstream SHA-256 matchedDownloadd2433372…790c26
1.1.9+2Cached · Upstream SHA-256 matchedDownload03012b0a…3bc0ad
1.1.10Cached · Upstream SHA-256 matchedDownload23c27164…999005
1.1.10+1Cached · Upstream SHA-256 matchedDownload18489bdd…d76c5a
1.1.11Cached · Upstream SHA-256 matchedDownloadafff5629…0ba0fe
1.1.11+1Cached · Upstream SHA-256 matchedDownload12faff3f…c8cd81
1.1.12Cached · Upstream SHA-256 matchedDownloadf3b9b6e4…d7d173
1.1.13Cached · Upstream SHA-256 matchedDownload101e1a04…3b92c6
1.1.14Cached · Upstream SHA-256 matchedDownload26d52073…7d3a2e
1.1.15Cached · Upstream SHA-256 matchedDownloadab9ff38f…b49ab1
1.1.16Cached · Upstream SHA-256 matchedDownload1b4b9e70…407aad
1.1.17Cached · Upstream SHA-256 matchedDownload557a315b…5d3331
1.1.18Cached · Upstream SHA-256 matchedDownloadca81fdfa…6725b0
1.1.19Cached · Upstream SHA-256 matchedDownloadd354a7ec…8ff0dc
1.1.20Cached · Upstream SHA-256 matchedDownload201e876b…f71c9b
1.2.0Cached · Upstream SHA-256 matchedDownload5a88dd14…f73a74
1.2.1Cached · Upstream SHA-256 matchedDownload06f0c50f…2cefa0
1.2.2Cached · Upstream SHA-256 matchedDownload98e7e94d…fef598
1.2.3Cached · Upstream SHA-256 matchedDownloadb9b3f391…ea129e
1.2.4On demandDownload09854c76…f72230
1.2.5Cached · Upstream SHA-256 matchedDownload7ee12e6d…73d172
1.2.6Cached · Upstream SHA-256 matchedDownload142a9146…4923a3
1.3.0Cached · Upstream SHA-256 matchedDownload4dca4feb…ca5682
1.3.1Cached · Upstream SHA-256 matchedDownload670a5909…c68f2b
1.3.2Cached · Upstream SHA-256 matchedDownloada8e2c197…faed65
1.3.3Cached · Upstream SHA-256 matchedDownload40c92d6d…526b2f
1.3.4Cached · Upstream SHA-256 matchedDownload4c9d2e71…89b50d

Dependencies

args "^2.3.0"

meta "^1.7.0"

path "^1.8.0"

path_parsing "^1.0.1"

vector_graphics_codec "^1.1.11+1"

xml "\u003e=6.3.0 \u003c=7.0.1"