To test this, run pub serve
, visit http://localhost:8080 and open the console:
The relevant code is in
web/index.dart
:
window.onMessage.listen((message) {
window.console.log(message);
window.console.log(message.source.location);
// Getting the href from the source location fails.
try {
print("Location href: ${message.source.location.href}");
} catch (error, stackTrace) {
window.console.error("Error getting href: $error\n$stackTrace");
}
});