Skip to content

Instantly share code, notes, and snippets.

@quietcricket
Created December 12, 2013 10:19
Show Gist options
  • Save quietcricket/7925851 to your computer and use it in GitHub Desktop.
Save quietcricket/7925851 to your computer and use it in GitHub Desktop.
Instantiate a Class by String
import "dart:mirrors";
MirrorSystem mirrors = currentMirrorSystem();
LibraryMirror lm = mirrors.findLibrary(new Symbol('libraryName'));
ClassMirror cm=lm.declarations[new Symbol('ClassName')] as ClassMirror;
InstanceMirror im=cm.newInstance(const Symbol(''), []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment