I am trying to pass a message from Javascript to Flutter using package flutter_js but it seems like it's not working cuz it shows No Channel " " registered
below is my code
Future<dynamic> getObjectName(JavascriptRuntime jsRuntime) async {
final completer = Completer();
JsEvalResult jsEvalResult = jsRuntime.evaluate("""
const Person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
// const personJson = JSON.stringify(Person);
sendMessage('passJson2Dart', JSON.stringify(Person));
""");
jsRuntime.onMessage('passJson2Dart', (args) {
print("test argument" + args);
Map<String, dynamic> person = json.decode(args);
print("test decode");
print(person);
return person;
});
// jsRuntime.onMessage('passJson2Dart', (args) {
// Map<String, dynamic> person = json.decode(args);
// completer.complete(person);
// });
// return completer.future;
}
Can I know how to add or register channel inside the JavascriptRuntime object