toImage method
Exports data to raw image.
If fit
is enabled, the path will be normalized and scaled to fit given width
and height
.
Implementation
Future<ByteData?> toImage({
int width = 512,
int height = 256,
Color? color,
Color? background,
double? strokeWidth,
double? maxStrokeWidth,
double border = 32.0,
ImageByteFormat format = ImageByteFormat.png,
bool fit = false,
}) async {
final image = await toPicture(
width: width,
height: height,
color: color,
background: background,
strokeWidth: strokeWidth,
maxStrokeWidth: maxStrokeWidth,
border: border,
fit: fit,
)?.toImage(width, height);
if (image == null) {
return null;
}
return image.toByteData(format: format);
}