toImage method
Implementation
Future<ui.Image> toImage() async {
var w = _widgetPainter.elementWidth;
var h = _widgetPainter.elementHeight;
var wInt = w.toInt();
var hInt = h.toInt();
var wD = w.toDouble();
var hD = h.toDouble();
var recorder = ui.PictureRecorder();
var canvas = Canvas(recorder, Rect.fromLTWH(0, 0, wD, hD));
_widgetPainter.paint(canvas, Size(wD, hD));
var picture = recorder.endRecording();
var image = await picture.toImage(wInt, hInt);
return image;
}