toImageBytes static method
Future<Uint8List?>
toImageBytes(
- GlobalKey<
State< key, {StatefulWidget> > - ChartImageExportFormat format = ChartImageExportFormat.png,
- double pixelRatio = 2.0,
- int jpegQuality = 90,
- Color jpegBackgroundColor = Colors.white,
Capture the widget attached to key in the requested image format.
Implementation
static Future<Uint8List?> toImageBytes(
GlobalKey key, {
ChartImageExportFormat format = ChartImageExportFormat.png,
double pixelRatio = 2.0,
int jpegQuality = 90,
Color jpegBackgroundColor = Colors.white,
}) {
return switch (format) {
ChartImageExportFormat.png => toPng(key, pixelRatio: pixelRatio),
ChartImageExportFormat.jpeg => toJpeg(
key,
pixelRatio: pixelRatio,
quality: jpegQuality,
backgroundColor: jpegBackgroundColor,
),
};
}