I'm trying to render SVG image that is bigger than ViewBox. To do this I'm using flutter_svg 0.19.0. For some reasons, the the image scales only to border of parent widget. However, if I specified smaller size than ViewBox, then image scales down correctly.
Creating SVG widget:
void setNewImage(String path) {
setState(() {
svg = SvgPicture.asset(
path,
alignment: Alignment.center,
allowDrawingOutsideViewBox: true,
width: 3000.0,
height: 5000.0,
clipBehavior: Clip.none,
);
});
}
Parent Widget:
Scaffold(
resizeToAvoidBottomPadding: false,
//avoid resize when keyboard is visible
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: ClipRRect(
child: Container(
color: Colors.transparent,
child: svg
)
)
)
Have you any idea how can I deal with this problem? Using SizedBox, Container with specified width and height also not works.
Edit: I found the solution by inserting svg Widget into Transform.scale() widget.
Scaffold(
resizeToAvoidBottomPadding: false,
//avoid resize when keyboard is visible
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: ClipRRect(
child: Container(
color: Colors.transparent,
child: Transform.scale(
scale: 2,
alignment: Alignment.topLeft,
child: svg)
)
)
)

