I want to write some Dart function "oKey" which calls JavaScript function "jsOnKey" (with success or exception too since cannot predict).
Next I want that JavaScript function "onKey" will call Dart function "callbackFromJs" to return control to Dart again (with success or exception).
Can you help me with this full flow - please assume SUCCESS or EXCEPTION on each border - I can not rely on 3rd party code - DART 2 JS 2 DART?
To make more context to this general question I put example code.
import 'dart:html';
void onKey(Event event) {
// I want to call something in javascript
// function callbackFromDart () {
// /* something */;
// /* call callbackJs in Dart - return control to dart */
// }
}
void callbackFromJs() {
// It should be called from JavaScript
}
void main() {
InputElement nameElement = querySelector('input[name=name]');
nameElement..placeholder = 'Enter text'
..onKeyUp.listen(onKey);
InputElement descriptionElement = querySelector('input[name=description]');
descriptionElement..placeholder = 'Enter text'
..onKeyUp.listen(onKey);
}