The documentation for the height and width parameters in the VectorGraphic widget states:
/// If specified, the width to use for the vector graphic. If unspecified,
/// the vector graphic will take the width of its parent.
final double? width;
/// If specified, the height to use for the vector graphic. If unspecified,
/// the vector graphic will take the height of its parent.
final double? height;
However, looking at the code this seems to be slightly misleading:
// If the caller did not specify a width or height, fall back to the
// size of the graphic.
// If the caller did specify a width or height, preserve the aspect ratio
// of the graphic and center it within that width and height.
double? width = widget.width;
double? height = widget.height;
if (height != null && !pictureInfo.size.isEmpty) {
width = height / pictureInfo.size.height * pictureInfo.size.width;
} else if (width != null && !pictureInfo.size.isEmpty) {
height = width / pictureInfo.size.width * pictureInfo.size.height;
}
Im not saying that there is anything necessarily wrong with the current implementation, but that the documentation for width and height is a bit misleading. Knowing that omitting these parameters results in the widget using the graphic size rather than the size of the parent layout widget would have saved me a lot of time figuring out why the SVGs in my app were looking blurry.
Could I please suggest that the documentation is updated/clarified? Thanks
The documentation for the height and width parameters in the VectorGraphic widget states:
However, looking at the code this seems to be slightly misleading:
Im not saying that there is anything necessarily wrong with the current implementation, but that the documentation for width and height is a bit misleading. Knowing that omitting these parameters results in the widget using the graphic size rather than the size of the parent layout widget would have saved me a lot of time figuring out why the SVGs in my app were looking blurry.
Could I please suggest that the documentation is updated/clarified? Thanks