adaptive_svg 0.5.0
adaptive_svg: ^0.5.0 copied to clipboard
Platform-adaptive SVG rendering. DOM <svg> on web, flutter_svg on native.
0.5.0 #
New: borderRadius parameter #
borderRadius— rounds the corners of the rendered SVG.- On web, applied as CSS
border-radius+overflow: hiddenon the wrapper<div>that hosts the platform view. Flutter'sClipRRectdoesn't reliably clipHtmlElementViewcontent, so the rounding is baked into the DOM container directly. - On native, falls back to wrapping the rendered widget in a
ClipRRect. - Available on both
AdaptiveSvg(...)andAdaptiveSvg.asset(...).
0.4.0 #
New: built-in gesture handling #
gestures(defaultfalse) — whentrue, wires up gesture handling that works the same on web and native. On web, the widget stacks aPointerInterceptor+GestureDetectorabove the platform view so pointer events route back into Flutter's gesture system; on native it just wraps the SVG with aGestureDetector. Whenfalse, no gesture widgets are built at all.- New callbacks (only fire when
gestures: true):onTap,onTapDown,onLongPress,onSecondaryTap,onHover. - New
mouseCursorparameter — defaults toSystemMouseCursors.clickwhenonTapis provided, otherwiseMouseCursor.defer.
Breaking: interceptPointer removed #
- The previous
interceptPointerparameter overlaid an emptyPointerInterceptorthat captured pointer events without forwarding them anywhere — it blocked the platform-view "hole" but had no gesture handler inside, so ancestorGestureDetector/InkWellwidgets still never received taps. The newgestures: trueAPI replaces it. - Migration: replace
AdaptiveSvg(svg, interceptPointer: true)withAdaptiveSvg(svg, gestures: true, onTap: ...).
0.3.0 #
0.2.0 #
Web rendering fixes #
- Parse SVG with
DOMParser('image/svg+xml')instead ofdiv.innerHTML = svg.innerHTMLparses input as HTML — SVG namespaces on child elements were inconsistently preserved, and<image href>elements could be misparsed as HTML<img>fallbacks (which silently dropped cross-origin loads). DOMParser parses the input as real XML, preserves every namespace, and exposes parse errors through a<parsererror>element. - Cache
HtmlElementViewview factories keyed by(svg, interactive, imageCrossOrigin). Previously every widget rebuild incremented a global_viewIdcounter and registered a brand-new platform view, leaking a factory per frame on any list / scroll-based UI.
New web-only options #
interactive(defaulttrue) — whenfalse, appliespointer-events: noneto both the container<div>and the injected<svg>root so taps and hovers flow through to the Flutter widget layer underneath. Useful for static thumbnails inside aGestureDetector.imageCrossOrigin(defaultnull) — when set toCrossOrigin.anonymousorCrossOrigin.useCredentials, applies thecrossoriginattribute to every<image>child of the parsed SVG. Required for cross-origin images to load underCross-Origin-Embedder-Policy: require-corp(used by apps that needSharedArrayBuffer, including Flutter Rust Bridge's threaded wasm mode) when the origin server only sendsAccess-Control-Allow-Originand notCross-Origin-Resource-Policy.
Both parameters are web-only and silently ignored on native platforms.
0.1.0 #
- Initial release
- DOM
<svg>rendering on web flutter_svgdelegation on native platforms