@@ -47,6 +47,11 @@ enum RenderingStrategy {
4747typedef VectorGraphicsErrorWidget =
4848 Widget Function (BuildContext context, Object error, StackTrace stackTrace);
4949
50+ /// The signature that [VectorGraphic.imageBuilder] uses to wrap the
51+ /// successfully loaded vector graphic widget.
52+ typedef VectorGraphicsImageWidget =
53+ Widget Function (BuildContext context, Widget child);
54+
5055/// A vector graphic/flutter_svg compatibility shim.
5156VectorGraphic createCompatVectorGraphic ({
5257 Key ? key,
@@ -61,6 +66,7 @@ VectorGraphic createCompatVectorGraphic({
6166 Duration ? transitionDuration,
6267 WidgetBuilder ? placeholderBuilder,
6368 VectorGraphicsErrorWidget ? errorBuilder,
69+ VectorGraphicsImageWidget ? imageBuilder,
6470 ColorFilter ? colorFilter,
6571 Animation <double >? opacity,
6672 RenderingStrategy strategy = RenderingStrategy .picture,
@@ -80,6 +86,7 @@ VectorGraphic createCompatVectorGraphic({
8086 transitionDuration: transitionDuration,
8187 placeholderBuilder: placeholderBuilder,
8288 errorBuilder: errorBuilder,
89+ imageBuilder: imageBuilder,
8390 colorFilter: colorFilter,
8491 opacity: opacity,
8592 strategy: strategy,
@@ -120,6 +127,7 @@ class VectorGraphic extends StatefulWidget {
120127 this .transitionDuration,
121128 this .placeholderBuilder,
122129 this .errorBuilder,
130+ this .imageBuilder,
123131 this .colorFilter,
124132 this .opacity,
125133 this .clipViewbox = true ,
@@ -140,6 +148,7 @@ class VectorGraphic extends StatefulWidget {
140148 this .transitionDuration,
141149 this .placeholderBuilder,
142150 this .errorBuilder,
151+ this .imageBuilder,
143152 this .colorFilter,
144153 this .opacity,
145154 this .strategy = RenderingStrategy .picture,
@@ -219,6 +228,13 @@ class VectorGraphic extends StatefulWidget {
219228 /// A callback that fires if some exception happens during data acquisition or decoding.
220229 final VectorGraphicsErrorWidget ? errorBuilder;
221230
231+ /// A builder that wraps the successfully loaded vector graphic widget.
232+ ///
233+ /// This builder is only called when the vector graphic has been successfully
234+ /// loaded and is ready to be painted. It can be used to apply decorations
235+ /// such as borders or shadows only when the image is available.
236+ final VectorGraphicsImageWidget ? imageBuilder;
237+
222238 /// Set transition duration while switching from placeholder to url image
223239 final Duration ? transitionDuration;
224240
@@ -517,6 +533,10 @@ class _VectorGraphicWidgetState extends State<VectorGraphic> {
517533 child: SizedBox .fromSize (size: pictureInfo.size, child: child),
518534 ),
519535 );
536+
537+ if (widget.imageBuilder != null ) {
538+ child = widget.imageBuilder !(context, child);
539+ }
520540 } else if (_error != null && widget.errorBuilder != null ) {
521541 child = widget.errorBuilder !(
522542 context,
0 commit comments