-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package:web usage for migration #229
Comments
A simple migration might look like the following: import 'dart:js_interop';
import 'dart:js_interop_unsafe'; // to dynamically set properties using []=
...
void _connectJsToFlutter({VoidCallback? then}) {
globalContext['$jsToDartConnectorFN$iframeViewType'] = (JSObject window) {
JSObject jsWindowObject = window;
for (final cb in widget.dartCallBacks) {
jsWindowObject[cb.name] = cb.callBack.toJS;
}
jsWindowObject.setProperty(webOnClickInsideIframeCallback.toJS, (String onClickCallbackObject) {
_handleOnIframeClick(onClickCallbackObject);
}.toJS);
webViewXController.connector = jsWindowObject;
then?.call();
};
} It's a little difficult to tell what the types of some of these objects are, but a few key points here are:
For more information, look at https://dart.dev/interop/js-interop/usage and https://dart.dev/interop/js-interop/js-types |
Thank you. Understood the usage now. Also could you let me know if I am doing the right way of doing onbeforeunload.
Or can I use a event listener to perform the same.
|
Yup, both should work (although that first one should take in the event as a parameter and I'm also not sure the |
Also I am doing callMethod from JsObject and passing For migration I am using JSObject from Also, am I using the correct method from JSObject? |
It's better practice to define an interface for the
What does the |
List contains dynamic type values. |
Assuming the nested List<dynamic> list = ...;
List<JSAny?> jsList = list.map((e) => jsify(e)).toList(); |
Where can I get more information or examples of JS interop usage other than https://dart.dev/interop/js-interop/usage? |
Besides the Of course, if you feel like you still have some questions, feel free to ask. If you want to provide feedback on what documentation might be useful for you or others, you can do so in https://github.com/dart-lang/site-www. There's some ongoing work there to get a "getting started" tutorial. |
I'm doing a migration to 'package:web' and 'dart:js_interop'. I'm currently using the context object from the 'dart:js' package to store functions in the window object reference. However, I've noticed that there's no direct way to access the context from the 'package:web'.
I need help with this migration. Below is the code snippet I need to migrate
Can you provide the correct usage of context and JsObject needed for the migration?
The text was updated successfully, but these errors were encountered: