dart:mirrors library
Basic reflection in Dart,with support for introspection and dynamic invocation.
Introspection is that subset of reflection by which a runningprogram can examine its own structure. For example, a functionthat prints out the names of all the members of an arbitrary object.
Dynamic invocation refers the ability to evaluate code thathas not been literally specified at compile time, such as calling a methodwhose name is provided as an argument (because it is looked upin 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 usinginstances of classSymbol. Whenever the doc speaks of an objectsof classSymbol denoting a name, it means the string thatwas used to constructs.
The documentation frequently abuses notation withDart pseudo-code such aso.x(a), whereo and a are defined to be objects; what is actually meant in thesecases iso'.x(a') whereo' anda' are Dart variablesbound too anda respectively. Furthermore,o' anda'are assumed to be fresh variables (meaning that they aredistinct from any other variables in the program).
Sometimes the documentation refers toserializable objects.An object is serializable across isolates if and only if it is an instance ofnum, bool, String, a list of objects that are serializableacross isolates, or a map with keys and values that are all serializable acrossisolates.
Status: Unstable
The dart:mirrors library is unstable and its API might change slightly as aresult of user feedback. This library is only supported by the Dart VM andonly available on some platforms.
Classes
- ClassMirror
- AClassMirror reflects a Dart language class.
- ClosureMirror
- AClosureMirror reflects a closure.
- CombinatorMirror
- A mirror on a show/hide combinator declared on a library dependency.
- DeclarationMirror
- ADeclarationMirror reflects some entity declared in a Dart program.
- FunctionTypeMirror
- AFunctionTypeMirror represents the type of a function in theDart language.
- InstanceMirror
- AnInstanceMirror reflects an instance of a Dart language object.
- IsolateMirror
- AnIsolateMirror reflects an isolate.
- LibraryDependencyMirror
- A mirror on an import or export declaration.
- LibraryMirror
- ALibraryMirror reflects a Dart language library, providingaccess to the variables, functions, and classes of thelibrary.
- MethodMirror
- AMethodMirror reflects a Dart language function, method,constructor, getter, or setter.
- Mirror
- AMirror reflects some Dart language entity.
- MirrorSystem
- AMirrorSystem is the main interface used to reflect on a set ofassociated libraries.
- ObjectMirror
- AnObjectMirror is a common superinterface ofInstanceMirror,ClassMirror, andLibraryMirror that represents their sharedfunctionality.
- ParameterMirror
- AParameterMirror reflects a Dart formal parameter declaration.
- SourceLocation
- ASourceLocation describes the span of an entity in Dart source code.
- TypedefMirror
- ATypedefMirror represents a typedef in a Dart language program.
- TypeMirror
- ATypeMirror reflects a Dart language class, typedef,function type or type variable.
- TypeVariableMirror
- ATypeVariableMirror represents a type parameter of a generic type.
- VariableMirror
- AVariableMirror reflects a Dart language variable declaration.
Functions
- currentMirrorSystem(
)→MirrorSystem - Returns aMirrorSystem for the current isolate.
- reflect(
dynamicreflectee)→InstanceMirror - Reflects an instance.
- reflectClass(
Typekey)→ClassMirror - Reflects a class declaration.
- reflectType(
Typekey, [List< Type> ?typeArguments])→TypeMirror - Reflects the type represented by
key.
Exceptions / Errors
- AbstractClassInstantiationError
- Error thrown when trying to instantiate an abstract class.