ConstructorDeclaration class abstract final

Represents a constructor of a Dart class, including its parameters, modifiers (const, factory), and the ability to create new instances.

This abstraction allows runtime instantiation of classes using metadata.

Example

class Person {
  final String name;
  final int age;

  Person(this.name, this.age);
}

final constructor = reflector.reflectConstructor(Person);
final person = constructor.newInstance({'name': 'Alice', 'age': 30});
print(person.name); // Alice

This is especially useful in frameworks like dependency injection, serialization, and code generation where runtime construction is needed.

Inheritance
Implementers

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

equalizedProperties() → List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
inherited
getAnnotations() → List<AnnotationDeclaration>
Returns all annotations applied to this declaration in source code.
inherited
getDebugIdentifier() → String
Returns the stable debug identifier for this entity.
inherited
getIsAbstract() → bool
Indicates whether this member is declared as abstract.
inherited
getIsConst() → bool
Returns true if this constructor is declared const.
getIsFactory() → bool
Returns true if this constructor is a factory.
getIsPublic() → bool
Indicates whether this declaration is publicly visible.
inherited
getIsStatic() → bool
Indicates whether this member is declared as static.
inherited
getIsSynthetic() → bool
Indicates whether this declaration is synthetic.
inherited
getName() → String
Returns the simple (unqualified) name of this declaration.
inherited
getParameters() → List<ParameterDeclaration>
Returns all parameters required by this constructor.
getParentClass() → LinkDeclaration?
Returns a link to the class that declares this member.
inherited
getSourceLocation() → Uri?
Returns the URI pointing to the source location where this declaration is defined.
inherited
getType() → Type
Returns the Dart Type represented by this declaration.
inherited
newInstance<T>(Map<String, dynamic> arguments) → T
Creates a new instance of the class using this constructor.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serialize(BinaryBuilder builder) → void
Serializes this declaration to binary format.
inherited
toJson() → Map<String, Object>
Serializes this declaration into a JSON-compatible map.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited