Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
List.cast() is not a native Array at browser env. with js-interop (same error between DDC and Dart2JS) #35622
Dart version: 2.1.0
We use a their-party library to interop with JS and they declare a
As you can see above, in the JS implementation, it will print "undefined" there.
We are trying to avoid this issue from our side, but it seems only to copy whole List to a new List and passes the new one to a js-interop method to solve the JS array issue.
@jumperchen thanks for reaching out.
There is a lot of work happening these days to improve js-interop, @jmesserly can hopefully provide more details.
As you noted, some operations in Dart that help provide appropriate strong types don't play well with JS-interop.
In this case, there are a few options you can use:
var list = <String>; // now you have a List<String> that is represented as a JsArray internally
void setValue(List<Object> ...);
@jmesserly - do we have plans to support non-native List types (like CastList) or plans to provide hints to guide developers on this?