Cannot read property of '__dartClass__' of undefined even though i set to a new instance

Issue

I was walking through my code, and started getting errors in my code saying:

Uncaught TypeError: Cannot read property '__dartClass__' of undefined

and when I looked into it more, I noticed that model is undefined, so my javascript mind just says: Oh this is a undefined has no property error. I took a step back to the parent, put in a print statement and see the model being set:

set("model", new SystemModel()..id=4);

and in the mark up, i pass it in correctly:

<my-component model="{{model}}" ..></my-component>

but it still doesnt understand it.

I then started to dissect it more, trying to see what happens if i assign it to something else first, such as:

var x = new SystemModel()..id=4;
print("x => $x");
set("model", x);

When I did this, I noticed that x was reporting it was an instance of SystemModel, but even then so, when referencing it in the subcomponent, it will kick up the above error.

I am currently using Dartium, but it seems that the property error was in the InteropBehavior._propertyChanged code. This confuses me, since I didnt think interop would be a thing since I am running it all within dart.

Part of me is thinking that even though this is recognized, some sort of error elsewhere might be preventing it from being passed around correctly. I havent noticed any errors which are making this jump out at me.

Here is the full print out of the error: enter image description here

Solution

This behavior is most probably related to a change in polymer that started notifing null properties from a certain version on and the “official” dart-polymer not being updated after that.

Try using the latest realeases from https://www.dart-polymer.com/polymer1/ and see if this is still happening.

Answered By – Vittorio Ballestra

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.