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
passing an instance of a domain model into Eval ? #79
Comments
Looking at the example with the If flinging random classes into eval is a pain, what about passing in a Map<String,String> ? I gave that a quick go and it had compile issues ... which I kind of expected as the whole Map thing is probably not allowed. I took the flutter_eval example, and added this to the code to be compiled ...
And then added this to the EvalWidget properties ... where mymap is a Map<String,String> with a few entries.
|
Hmm, can you try using an $Map instead of an $Object? If there's still an error please paste the message. |
Somehow I missed $Map, which sounds perfect. I tried the following 2 way to pass in my map ...
and get this error in my console ...
|
That looks like an argument count mismatch to me. Are you sure the constructor is still taking 2 arguments? |
Well you nailed that one ... my fault after too much copy/paste trial/error stuff. Thanks for all the help btw. Now I am getting ...
It's not liking my passed in Map<String,String>, it looks like in the eval'd code the Map may actually be null. Here is the eval'd widget code (mostly just the normal example code) and the code that creates the widget ...
I am using creating the widget like so ...
|
It looks like When I go to use the map in the eval'd widget like this https://github.com/ethanblake4/dart_eval/blob/master/lib/src/eval/shared/stdlib/core/map.dart#L14 |
First of all, you should be using Anyway, after a little investigation it looks like you have to box the contents of the $Map too, not just the map itself. So instead of: $Map<String, String>('map', {"test": "value"}) you'd put: $Map<$String, $String>.wrap({$String("test"): $String("value")}) Hope that helps! |
With that example it is starting to make some sense. But alas, with the above change to calling EvalWidget (and with the same widget code) ...
|
Hi @aktxyz sorry for the late reply, I have been busy with family. If you can link me to a repo containing the full code that causes the error I'll take another look. |
hmm, that is great to know, I will get a repo together to share, thanks ! |
Ha, of course when I make a small sample repo, it works fine. It turns out my main issue was accessing the length property on the map ... which was causing this error Other errors were caused by flailing around trying to see what caused the NullCheck error. Thanks !
|
Ah yeah, that will be fixed when I get around to #9. Glad it's working otherwise! |
I asked something similar in the flutter_eval project, but now that I think about it, this is probably more of a dart_eval thing.
I have a package with a bunch of class definitions that contain the main models for my project.
I would like to pass an instance of one of these models into the eval'd code and use some of the model properties in the eval'd code.
Is there a way to do something like that?
The text was updated successfully, but these errors were encountered: