I am trying to call a method of a class that I only know by name as a String. Now therefore I would need a ClassMirror of that class that allowes me to instantiate an instance. However, creating ClassMirrors seems to be only possible by entering a type using reflectClass(Type)
or by passing an already existing instance of that class into reflect(dynamic)
. So these aren`t helping if I only have a String.
In Java you can do this pretty easily, by calling Class.forName(String)
. Then you would get a Constructor instance, make it accessibly and call it.
Does anyone know if this is even possible in dart? What seems weird is that once you have a ClassMirror you can access fields and methods by passing symbols, which can be created by Strings.
Aucun commentaire:
Enregistrer un commentaire