toImage method
Future<ByteData?>
toImage({
- int width = 512,
- int height = 256,
- Color? color,
- Color? background,
- double? strokeWidth,
- double? maxStrokeWidth,
- HandSignatureDrawer? drawer,
- double border = 0.0,
- ImageByteFormat format = ImageByteFormat.png,
- bool fit = false,
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,
HandSignatureDrawer? drawer,
double border = 0.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,
drawer: drawer,
border: border,
fit: fit,
)?.toImage(width, height);
if (image == null) {
return null;
}
return image.toByteData(format: format);
}