-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Open
Labels
c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: flutter_svgThe Flutter SVG drawing packagesThe Flutter SVG drawing packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-engineOwned by Engine teamOwned by Engine team
Description
Use case
Currently, SvgPicture provides placeholderBuilder and errorBuilder, but it lacks a "success" builder equivalent to imageBuilder in CachedNetworkImage.
If a developer wants to apply a decoration (like a Border, BoxShadow, or BorderRadius) specifically to the resulting image, they must wrap the SvgPicture widget in a Container or DecoratedBox. However, this decoration is then visible even when the image is loading (placeholder) or when it fails (error).
Proposal
It would be really useful to have a imageBuilder property added to SvgPicture constructors. This builder should only trigger once the SVG has been successfully parsed and is ready to be painted.
Proposed API
SvgPicture.asset(
'assets/icons/logo.svg',
imageBuilder: (BuildContext context, Widget image) {
return Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.blue, width: 2),
borderRadius: BorderRadius.circular(8),
),
child: image,
);
},
placeholderBuilder: (context) => CircularProgressIndicator(),
)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: flutter_svgThe Flutter SVG drawing packagesThe Flutter SVG drawing packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-engineOwned by Engine teamOwned by Engine team