Is there any way to pass Dart variables to another

2019-02-20 05:24发布

问题:

I know that I can use local storage, cookies and postMessage but all these methods only accept simple types. I want to pass objects and lists directly to the other window.

I found a similar question but using javascript. I'd like to do something just like Victor pointed in the following link.

Can I pass a JavaScript variable to another browser window?

Trying anything similar in Dart gives me a warining even before running.

var popup = window.open('popup.html', ''); popup.variable = localVariable; //warning here

回答1:

Passing objects is not possible.

You can serialize to JSON to make it a simple type and pass it using postMessage and then deserialize. Lists and maps containing only simple types should work with postMessage.



标签: dart