Dart Web UI - Passing object data to a component

2019-07-23 17:45发布

问题:

I am trying to pass data to custom component. The example at http://www.dartlang.org/articles/web-ui/#pass-data-to-component works good.

But I'm trying to pass a JsonObject var, and it crash with this message:

Exception: type 'String' is not a subtype of type 'JsonObject' of  'value'. 

So it seems like I can pass only strings and numbers data?

回答1:

This works for me when passing the Map class. Perhaps you could change your code to use the dart:json library and the core library Map class, rather than the third-party JsonObject.

JsonObject also uses the mirrors library, which is not yet supported in dart2js, so may not be a good fit for browser based development.