onmessage 0.1.2 onmessage: ^0.1.2 copied to clipboard
A stream wrapping JavaScript's `window.onmessage` that is safe to import even on platforms other than web.
import 'package:flutter/material.dart';
import 'package:onmessage/onmessage.dart';
/// This app prints all messages it receives from other frames in web.
void main() {
OnMessage.instance.stream.listen((MessageEvent event) {
print(event);
});
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Container(),
);
}
}