printData method
Future
printData(
- dynamic data
)
override
Implementation
@override
Future printData(data) async {
final id = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
final iframe = IFrameElement()
..id = id
..style.display = "none"
;
final blob = Blob([data], 'application/pdf');
final url = Url.createObjectUrlFromBlob(blob);
iframe.src = url;
document.body?.append(iframe);
final contentWindow = context.callMethod('eval', ['document.getElementById("$id").contentWindow']);
contentWindow.callMethod('eval', ['window.print();']);
//TODO нужно будет сделать удаление iframe
contentWindow.callMethod('setTimeout', [
() => iframe.remove(),
1000 * 60 * 5,
]);
return Future(() => url);
}