Reflectable class Null safety
Reflectable is used as metadata, marking classes for reflection.
If a class has an instance of a subclass of this class in its
metadata1 then it will be included in the root set of classes
with support for reflection based on this package. Other classes
outside the root set may also be included, e.g., if it is specified
that all subtypes of a given class in the root set are included.
For classes and instances not included, all reflective operations
will throw an exception. For included classes and instances,
invocations of the operations in mirrors.dart are supported if
the ReflectCapability values given as constructor arguments
include the capability to run those operations; the operations
will throw an exception if the relevant capability is not included.
Terminology: We use the term reflector class to denote a
direct subclass of Reflectable with a zero-argument
constructor that is used as metadata on a class in the target
program in one of the two supported manners: as a
constructor expression (
@MyReflectable()), or as an identifier
@myReflectable) which is a top-level
const whose value is
an instance of the given reflector class
const myReflectable = const MyReflectable();). We use the
term reflector-annotated class to denote a class whose
metadata includes an instance of a reflector class.
Note that the role played by this class includes much of the role played by a MirrorSystem with dart:mirrors.
- Currently, the only setup which is supported is when
the metadata object is an instance of a direct subclass of the
class Reflectable, say
MyReflectable, and that subclass defines a
constconstructor taking zero arguments. This ensures that every subclass of Reflectable used as metadata is a singleton class, which means that the behavior of the instance can be expressed by generating code in the class. Generalizations of this setup may be supported in the future if compelling use cases come up.
- Implemented types
- Reflectable([ReflectCapability? cap0, ReflectCapability? cap1, ReflectCapability? cap2, ReflectCapability? cap3, ReflectCapability? cap4, ReflectCapability? cap5, ReflectCapability? cap6, ReflectCapability? cap7, ReflectCapability? cap8, ReflectCapability? cap9])
Const constructor, to enable usage as metadata, allowing for varargs
style invocation with up to ten arguments.
Returns an Iterable of all the classes that can be reflected over in
Specifies limits on the support for reflective operations on instances
of classes having an instance of this ReflectableBase as metadata.
- hashCode → int
The hash code for this object. [...]
Returns a map of all libraries in the current isolate.
- runtimeType → Type
A representation of the runtime type of the object.
Object reflectee) → bool
Returns true if this reflector has capabilities for the given instance.
Type type) → bool
Returns true if this reflector has capabilities for the given Type.
String libraryName) → LibraryMirror
Returns a mirror of the given library
Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
Object reflectee) → InstanceMirror
Returns a mirror of the given object
Type type) → TypeMirror
Returns a mirror of the given type
) → String
A string representation of this object. [...]