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

0

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).
Posted by: Guest on January-21-2020

Code answers related to "dart the operator [] isn't defined for the class Type"

Code answers related to "Dart"

Browse Popular Code Answers by Language