forName static method

ClassMirror forName(
  1. String qname
)

Return the ClassMirror of the qualified class name

  • qname - qualified class name (libname.classname), such as dart:core.List and rikulo_mirrors.ClassMirror.

Implementation

static ClassMirror forName(String qname) {
  final splited = _splitQualifiedName(qname);

  try {
    final lib = currentMirrorSystem().findLibrary(Symbol(splited["lib"]!)),
      klass = lib.declarations[Symbol(splited["class"]!)];
    if (klass is ClassMirror)
      return klass;
  } catch (e) {
    // findLibrary now throws if the symbol isn't there.
    throw NoSuchClassError(qname);
  }
  throw NoSuchClassError(qname);
}