dart:mirrors library

Basic reflection in Dart, with support for introspection and dynamic invocation.

Basic reflection in Dart, with support for introspection and dynamic invocation.

Introspection is that subset of reflection by which a running program can examine its own structure. For example, a function that prints out the names of all the members of an arbitrary object.

Dynamic invocation refers the ability to evaluate code that has not been literally specified at compile time, such as calling a method whose name is provided as an argument (because it is looked up in a database, or provided interactively by the user).

How to interpret this library's documentation

As a rule, the names of Dart declarations are represented using instances of class Symbol. Whenever the doc speaks of an object s of class Symbol denoting a name, it means the string that was used to construct s.

The documentation frequently abuses notation with Dart pseudo-code such as o.x(a), where o and a are defined to be objects; what is actually meant in these cases is o'.x(a') where o' and a' are Dart variables bound to o and a respectively. Furthermore, o' and a' are assumed to be fresh variables (meaning that they are distinct from any other variables in the program).

Sometimes the documentation refers to serializable objects. An object is serializable across isolates if and only if it is an instance of num, bool, String, a list of objects that are serializable across isolates, or a map with keys and values that are all serializable across isolates.

Status: Unstable

The dart:mirrors library is unstable and its API might change slightly as a result of user feedback. This library is platform dependent and therefore it has implementations for both dart2js and the Dart VM. Both are under development and may not support all operations yet.

Classes

MirrorSystem
A MirrorSystem is the main interface used to reflect on a set of associated libraries.
Mirror
A Mirror reflects some Dart language entity.
IsolateMirror
An IsolateMirror reflects an isolate.
DeclarationMirror
A DeclarationMirror reflects some entity declared in a Dart program.
ObjectMirror
An ObjectMirror is a common superinterface of InstanceMirror, ClassMirror, and LibraryMirror that represents their shared functionality.
InstanceMirror
An InstanceMirror reflects an instance of a Dart language object.
ClosureMirror
A ClosureMirror reflects a closure.
LibraryMirror
A LibraryMirror reflects a Dart language library, providing access to the variables, functions, and classes of the library.
LibraryDependencyMirror
A mirror on an import or export declaration.
CombinatorMirror
A mirror on a show/hide combinator declared on a library dependency.
TypeMirror
A TypeMirror reflects a Dart language class, typedef, function type or type variable.
ClassMirror
A ClassMirror reflects a Dart language class.
FunctionTypeMirror
A FunctionTypeMirror represents the type of a function in the Dart language.
TypeVariableMirror
A TypeVariableMirror represents a type parameter of a generic type.
TypedefMirror
A TypedefMirror represents a typedef in a Dart language program.
MethodMirror
A MethodMirror reflects a Dart language function, method, constructor, getter, or setter.
VariableMirror
A VariableMirror reflects a Dart language variable declaration.
ParameterMirror
A ParameterMirror reflects a Dart formal parameter declaration.
SourceLocation
A SourceLocation describes the span of an entity in Dart source code.
Comment
Class used for encoding comments as metadata annotations.
MirrorsUsed
Annotation describing how "dart:mirrors" is used (EXPERIMENTAL).

Functions

currentMirrorSystem ( ) → MirrorSystem
Returns a MirrorSystem for the current isolate.
reflect ( Object reflectee ) → InstanceMirror
Reflects an instance. Returns an InstanceMirror reflecting reflectee. If reflectee is a function or an instance of a class that has a call method, the returned instance mirror will be a [Closure...
reflectClass ( Type key ) → ClassMirror
Reflects a class declaration. Let C be the original class declaration of the class represented by key. This function returns a ClassMirror reflecting C.
reflectType ( Type key ) → TypeMirror
This function returns a TypeMirror reflecting the type represented by key.