Skip to content
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

Cannot insert a script-generated map into a dart generated list #8

Open
rockingdice opened this issue Feb 26, 2021 · 2 comments
Open

Comments

@rockingdice
Copy link
Contributor

rockingdice commented Feb 26, 2021

Consider I have a dart list containing dart maps:

List<Map<String, dynamic>> mapList = [];

If I use the mapList as a parameter, then in the script:

fun exec(mapList){      
      var m : Map<String> = {'key': 'value'}
      mapList.add(m)
}

The add will throw an exception because the actual dart type of m is LinkedMap<dynamic, dynamic>, which cannot be inserted into a List<Map<String, dynamic>>.

I think the Map<String, any> is just like dart type Map<String, dynamic> . Can you make this possible?

@rockingdice rockingdice changed the title Cannot insert a script-generated map into one from dart Cannot insert a script-generated map into a dart generated list Feb 26, 2021
@rockingdice
Copy link
Contributor Author

It's very handy to make a Map<String, dynamic> since it can be converted to a JSON object without any effort.

@hythl0day
Copy link
Member

For now, omit the type annotation to avoid the type checker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants