svg_pic_editor 5.1.0
svg_pic_editor: ^5.1.0 copied to clipboard
A dependency-free Flutter widget to load, edit and render SVGs (CSS, @keyframes and SMIL animations included) across all platforms.
Changelog #
5.1.0 #
New Features #
- Added
ElementEdit.customAttributes(List<String>?): an escape hatch for setting arbitrary raw XML attributes (e.g.'preserveAspectRatio=xMidYMid slice','data-tag=hero') that aren't covered by the typed fields (fillColor,strokeColor,opacity, etc.). Each entry is a literal"attributeName=value"string; entries without an=are ignored. Applied last, so it can also override a typed field's result for the same element.
5.0.0 #
Breaking Changes #
flutter_svgis no longer a dependency, andsvg_pic_editor.dartno longer re-exportspackage:flutter_svg/flutter_svg.dart. Code that importedflutter_svgtypes (e.g.SvgPicture,ColorFilterhelpers) through this package needs to depend onflutter_svgdirectly if it still needs them.SvgEditorCore's lower-levelXmlDocument/XmlElementparameters now come from the package's ownxml_litemodule (exported fromsvg_pic_editor.dart) instead ofpackage:xml.SvgEditorCore.cleanSvgno longer strips<style>tags (only<script>) — CSS is now parsed and applied instead of discarded.
New Features #
- Zero third-party dependencies. The package now has no runtime dependencies beyond the Flutter SDK itself: SVG parsing (
lib/src/xml), network loading (lib/src/net,dart:io/dart:html), and now SVG rendering (lib/src/render) are all built in-house. - Built-in rendering engine (
NativeSvgPicture, also exported): paints shapes directly viaCustomPainter/Canvas—rect,circle,ellipse,line,polyline,polygon, fullpathdata (including arcs),g/use/basictext,transform, and basiclinearGradient/radialGradient. - CSS support:
<style>blocks are parsed and resolved (tag/class/id selectors and compounds, proper cascade/specificity), instead of being deleted bycleanSvg. - Animation support: CSS
@keyframes+animationshorthand, and SMIL<animate>/<animateTransform>/<animateColor>, are interpreted and played back automatically. A static SVG (no animation elements) never starts an animation ticker, so this has no cost for the common case.
Fixes #
getParts,getColorsandlistenEditcould crash withsetState() or markNeedsBuild() called during buildwhen the SVG source was a.string()(no asset/network delay) and the callback calledsetStateon an ancestor widget — a very common pattern. These callbacks are now always deferred to right after the current frame, so callingsetStatefrom them is safe regardless of the source type.
Known limitations #
- No
<clipPath>,<mask>,<pattern>,<filter>, markers, or<animateMotion>. - Gradients are objectBoundingBox-only (no
gradientTransform/userSpaceOnUse). - SMIL
keyTimes/calcMode(spline/discrete) are not supported; interpolation is always linear betweenvalues. <text>has notspansub-positioning; it renders as a single run at(x, y).
4.0.0 #
New Features #
- Added support for
borderRadiuson<rect>elements inElementEditandSvgEditorCore.
Improvements #
- Upgraded the package to use the new Flutter Color API (
r,g,b,aandtoARGB32()), resolving all static analysis deprecation warnings. - Upgraded environment constraints to Flutter
>=3.22.0and Dart>=3.4.0to support modern APIs. - Created a robust
.pubignorefile to exclude build caches, local configuration files, and thedocsweb helper from the published package, reducing the package size significantly. - Cleaned up unused local variables and resolved minor warnings.
3.2.0 #
Improvements #
- Refined the
onTapfunctionality, now supporting both void and modified SVG string returns for better flexibility. - Enhanced error handling in the
SvgPicEditorwidget, ensuring smoother user experience when errors occur. - Updated the
modifiedSvgStringupdate logic to improve the reactivity and ensure faster rendering.
New Features #
- Introduced the
onTapcallback function, allowing users to trigger actions when the SVG is tapped, either with the modified SVG string or without any return value. - Added shimmer effect loading for a smoother experience when the SVG is being processed.
Fixes #
- Corrected a potential issue with the SVG string processing, improving the integrity of the final modified output.
- Minor optimizations in the way SVG parts are loaded for performance improvements.
Notes #
- This update focuses on improving the interactivity and error resilience of the
SvgPicEditor, alongside optimizing the performance during SVG manipulation and loading. - Users are encouraged to explore the new
onTapfunctionality to enhance user interactivity with SVG elements.
3.0.0 #
Improvements #
- Enhanced the search system with improved query handling for better performance and flexibility.
- Refined the
listemEditfunctionality, which now returns the SVG string whenever an element is edited, including support for nullable attributes. - Introduced the
getColorsfunction that returns aSvgColorElement, containing two attributes: one for the color and another for a list of associatedSvgElementelements. - Renamed the
ElementSvgclass toElementEditto better reflect its new functionality.
New Features #
- Added the
listemEditfunction, which provides real-time SVG string updates when elements are modified. - Introduced
getColorsfunction to facilitate easier extraction and modification of colors within an SVG.
Notes #
- This update focuses on enhancing the search functionality, adding new element editing features, and improving the handling of colors in SVG elements.
- The renaming of
ElementSvgtoElementEditreflects a more appropriate naming convention after the recent changes. - Users are encouraged to try the new
listemEditandgetColorsfunctionalities to streamline their workflows.
2.0.1 #
2.0.0 #
Improvements #
- Refined the
queryAdvancedfunction to boost performance and readability. - Enhanced querying capabilities with simplified attribute handling and more efficient filtering logic.
- Optimized XML element filtering to increase execution speed.
New Features #
- Added an animation extension to
SvgPicEditor, offering ready-to-use and customizable animations.
Notes #
- This update focuses on improving user experience with faster and more efficient XML querying.
- Users are encouraged to explore the new querying capabilities and the animation extension to ensure they meet their needs.
1.2.0 #
Added #
- Support added for multiple platforms (Android, iOS, Web, Windows, macOS, Linux).
- Adjustments to the homepage for better presentation and documentation.
- New folder structure to facilitate code maintenance and navigation within the project.
Fixes #
- Removed deprecated color property in SvgPicture.
- Adjustments to dependencies to support the new platforms.
- Updated examples in the README to reflect recent changes.
Notes #
- This version includes significant improvements in project structure and user experience.
- Multi-platform support allows for broader reach and better compatibility.
- We recommend users test the functionalities on all supported platforms to ensure a consistent experience.
1.1.3 #
1.1.2 #
1.1.1 #
1.1.0 #
Added #
- Initial implementation of SvgPicEditor.
- Support for loading SVG from assets, URLs, and strings.
- ElementSvg class for modifying SVG elements.
- Usage examples in the README.
- Shimmer effect loading implementation while SVG is being processed.
- Improved SVG cleanup method for better compatibility.
Fixes #
- Adjusted factory methods in SvgPicEditor; the first argument is now automatically the context.
- Updated README examples to reflect recent changes.
- Fixed color naming convention to color.
- Code review to eliminate redundancies and improve maintainability.
- Performance optimizations for SVG loading.
- Improved error handling during loading.
Notes #
- This is the 1.1.0 release and may contain bugs or limitations.
- Enhanced user experience during SVG loading.
- General improvements in code quality and documentation.