Instantiate a class from a string

You need to know the library name and class name to make things work properly. Assume you know both, the below example will instantiate the TestClass and call doStuff on it. library test; import “dart:mirrors”; class TestClass { doStuff() => print(“doStuff was called!”); } main() { MirrorSystem mirrors = currentMirrorSystem(); LibraryMirror lm = mirrors.libraries[‘test’]; ClassMirror … Read more