Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically get field of object in dart

How do I dynamically get a field from an object instance?

I have this code:

var reflection = reflect(this);
InstanceMirror field = reflection.getField(new Symbol(fieldName));

When I print the variable field I get InstanceMirror on <'value of field'> so it's all there,... but how to actually get the value?

like image 229
enyo Avatar asked May 01 '13 19:05

enyo


2 Answers

Once you get your InstanceMirror representing the field, simply call field.reflectee.

like image 128
Alexandre Ardhuin Avatar answered Oct 19 '22 00:10

Alexandre Ardhuin


I found it. The actual value is in the InstanceMirror .reflectee property.

like image 35
enyo Avatar answered Oct 19 '22 01:10

enyo