metaTargets property

dynamic metaTargets
final

A list of classes that when used as metadata indicates a reflective target. See also targets.

The following text is non-normative:

The format for specifying the list of classes is the same as used for specifying targets. However, as a library cannot be used as a metadata annotation in Dart, adding a library to the list of metaTargets has no effect. In particular, adding a library to metaTargets does not make the library's classes valid metadata annotations to enable reflection.

If an instance of a class specified in metaTargets is used as metadata annotation on a library, class, field or method, that library, class, field or method is added to the set of targets for reflection.

Example usage:

library example;
@MirrorsUsed(metaTargets: "example.Reflectable")
import "dart:mirrors";

class Reflectable {
  const Reflectable();
}

class Foo {
  @Reflectable()
  reflectableMethod() { ... }

  nonReflectableMethod() { ... }
}

In the above example. reflectableMethod is marked as reflectable by using the Reflectable class, which in turn is specified in the metaTargets annotation.

The method nonReflectableMethod lacks a metadata annotation and thus will not be reflectable at runtime.

Implementation

final metaTargets;

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-mirrors/MirrorsUsed/metaTargets.html