svg_painter 0.2.0
svg_painter: ^0.2.0 copied to clipboard
A code generator that compiles SVG files into Flutter CustomPainter code.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.2.0 - 2026-01-31 #
Added #
Dynamic Properties
- ID-Based Exposure: Automatically generates fields for elements with IDs (e.g.
final Color? myCircleFill). - Indexed Exposure: Generates fields for elements without IDs using index-based naming (e.g.
final Color? fill1) when enabled viaexposureMode: SvgExposureMode.indexed. - Property Mapping: Allows renaming of exposed properties via
propertyMappingin the annotation (e.g.{'fill1': 'primaryColor'}). - Dynamic Style Inheritance: Overriding a group's property (e.g.
g1Fill) now correctly propagates to all inheriting children.
Widget Generation
- Generates a
StatelessWidgetwrapper (e.g.MyIconWidget) for easier consumption. - Exposes all dynamic properties as constructor parameters.
- Supports
BoxFit,Alignment, andwidth/heightsizing.
CurrentColor Support
- Maps SVG
currentColorkeyword to a primarycolorproperty on the generated Widget/Painter. - Defaults to
IconTheme.of(context).colorin the generated Widget.
Changed #
- Refactoring: Significant code cleanup and refactoring for better maintainability and type safety.
- Dependency: Updated
svg_painter_annotationto^0.2.0.
0.1.1 - 2026-01-26 #
Fixed #
- Added example file for pub.dev documentation
- Fixed monorepo dependency resolution for CI
0.1.0 - 2026-01-25 #
Added #
SVG Elements
<svg>- Root element with viewBox support<circle>- Circle shapes<ellipse>- Ellipse/oval shapes<rect>- Rectangles with optional rounded corners (rx/ry)<line>- Line segments<path>- Full path data support (M, L, H, V, C, S, Q, T, A, Z commands)<polygon>- Closed polygon shapes<polyline>- Open polyline shapes<text>- Basic text rendering<g>- Group element for organizing shapes<defs>- Definition container for reusable elements<use>- Reference and reuse defined elements<linearGradient>- Linear gradient fills/strokes<radialGradient>- Radial gradient fills/strokes<stop>- Gradient color stops
SVG Attributes
fillandstroke- Solid colors and gradient referencesfill-opacityandstroke-opacity- Transparency controlopacity- Element-level opacitystroke-width- Stroke thicknessstroke-linecap- Line end styles (butt, round, square)stroke-linejoin- Line join styles (miter, round, bevel)stroke-dasharray- Dashed line patternstransform- All transform functions (translate, scale, rotate, skewX, skewY, matrix)viewBox- Coordinate system definitionstyle- Inline CSS style parsing
Color Formats
- Named colors (140 SVG/CSS color names)
- Hex colors (
#RGB,#RRGGBB) - RGB/RGBA (
rgb(),rgba()) - HSL/HSLA (
hsl(),hsla()) noneandcurrentColorkeywords
Build System
build_runnerintegration for automatic code generation- Annotation-based SVG file selection (
@SvgPainter)
Notes #
- Generated painters extend Flutter's
CustomPainter - Automatic scaling to fit target dimensions while preserving aspect ratio
- Full support for nested groups and transforms