0
Q:

dart the operator [] isn't defined for the class Type

The Object class does not have any [] operator. I am assuming you want a behavior similar to JavaScript, but Dart is not JavaScript. You cannot look up members using [] and a string name o["foo"], you have to write o.foo.
This is a deliberate choice, and if you want to access a member by a name that is only known as a string at runtime, that is reflection and you need to use dart:mirrors for it (on a platform supporting dart:mirrors).

There are no plans to allow reflection directly on Object.

Aside from that, it would break every other class which currently extend Object and implement operator[] (like Map).
0

New to Communities?

Join the community