Introspected class
Marks a class whose properties, constructor and methods the generator describes, so the framework can read and fill its objects without reflection.
Dart has no runtime reflection in Flutter or compiled programs, so
anything that must list or set the fields of an object it did not write
needs a description generated at build time. Put @Introspected() on
the classes that are bound from requests or configuration, validated,
turned into JSON or used in SpEL expressions. Micronaut's
@Introspected works the same way.
// A form that is validated and bound from request data.
@Introspected()
class Address {
@NotBlank()
String city = '';
String? zip;
}
// The generated BeanIntrospection is registered by the module, so:
BeanWrapper(Address()).setPropertyValue('city', 'Lyon');
Spring (Java): no annotation is needed; Spring discovers properties at
runtime with java.beans.Introspector (getters and setters) and
reflection. Micronaut's @Introspected is the closest match.
class Address {
private String city;
public String getCity() { return city; }
public void setCity(String city) { this.city = city; }
}
Classes of other packages (a shared DTO package, ...) are introspected
by listing them: @Introspected(classes: [ExternalDto]) on any class of
the scanned package. Classes of the same package used by an introspected
class (property and constructor types) are introspected automatically.
@Introspected() describes everything about a class. A class the build
finds in use without it (a controller's return type, a request body, a
client's answer) is described only for that use, see
IntrospectionPart; the annotation is the way to ask for all of it.
Constructors
-
Introspected({List<
Type> classes = const []}) -
Introspects the annotated class and the
classeslisted.const
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited