Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/flutter_svg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ canvas.drawPicture(pictureInfo.picture);
// Or convert the picture to an image:
final ui.Image image = pictureInfo.picture.toImage(...);

// Or convert the picture to a scaled image:
const double targetWidth = 512;
const double targetHeight = 512;
final ui.PictureRecorder pictureRecorder = ui.PictureRecorder();
final ui.Canvas canvas = Canvas(pictureRecorder, Rect.fromPoints(Offset.zero, Offset(targetWidth, targetHeight)));
canvas.scale(targetWidth / pictureInfo.size.width, targetHeight / pictureInfo.size.height);
canvas.drawPicture(pictureInfo.picture);
final ui.Image scaledImage = await pictureRecorder.endRecording().toImage(targetWidth.ceil(), targetHeight.ceil());

pictureInfo.picture.dispose();
```

Expand Down