I would like to know how to print reports on Dart.
Basically, this is the activity flow:
- User clicks "Report" button.
- New browser window is created.
- Related data gets placed in the new window.
Of course that if there's any API to do that, I would use it.
So far, I've tried to create a new window, add onMessage listener on it and call postMessage on the main class to send data. However, it didn't work. The message never gets to the other side (main > new browser window).
Main Dart Class
var reportWindow;
void createReportWindow() {
reportWindow = window.open("report.html", "");
}
void sendMessage(String message) {
reportWindow.postMessage(message, "*");
}
Report Dart Class (linked to report.html)
void startListening() {
window.onMessage.listen((e) {
print(e.data.toString());
});
}