StandardConstructorDeclaration class final
A standard implementation of ConstructorDeclaration that provides metadata and instantiation logic for class constructors.
This class encapsulates the constructor name, owning class and library,
parameter list, annotations, and information such as whether the constructor
is a const or a factory. It also optionally provides a factory function
to support reflective instantiation.
Example
final constructor = StandardReflectedConstructor(
name: 'MyClass',
parentLibrary: myLibrary,
parentClass: myClass,
isConst: true,
parameters: [
StandardReflectedParameter(name: 'value', type: intType),
],
);
final instance = constructor.newInstance({'value': 42});
This creates a reflective representation of a MyClass constructor and
uses it to create a new instance.
- Inheritance
-
- Object
- BaseDeclaration
- Declaration
- StandardDeclaration
- StandardEntityDeclaration
- StandardSourceDeclaration
- StandardConstructorDeclaration
- Implemented types
Constructors
-
StandardConstructorDeclaration({required String name, required Type type, required bool isPublic, required bool isSynthetic, required LinkDeclaration parentClass, List<
AnnotationDeclaration> annotations = const [], List<ParameterDeclaration> parameters = const [], Uri? sourceLocation, bool isFactory = false, bool isConst = false}) - A standard implementation of ConstructorDeclaration that provides metadata and instantiation logic for class constructors.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isConst ↔ bool
-
getter/setter pair
- isFactory ↔ bool
-
getter/setter pair
-
parameters
↔ List<
ParameterDeclaration> -
getter/setter pair
- parentClass ↔ LinkDeclaration
-
getter/setter pair
- 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, andtoString.override -
getAnnotations(
) → List< AnnotationDeclaration> -
Returns all annotations applied to this declaration in source code.
inherited
-
getDebugIdentifier(
) → String -
Returns the stable debug identifier for this entity.
override
-
getIsAbstract(
) → bool -
Indicates whether this member is declared as
abstract.override -
getIsConst(
) → bool -
Returns
trueif this constructor is declaredconst.override -
getIsFactory(
) → bool -
Returns
trueif this constructor is afactory.override -
getIsPublic(
) → bool -
Indicates whether this declaration is publicly visible.
inherited
-
getIsStatic(
) → bool -
Indicates whether this member is declared as
static.override -
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.
override
-
getParentClass(
) → LinkDeclaration -
Returns a link to the class that declares this member.
override
-
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.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
BinaryBuilder builder) → void -
Serializes this declaration to binary format.
override
-
toJson(
) → Map< String, Object> -
Serializes this declaration into a JSON-compatible map.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
deserialize(
BinaryReader reader) → StandardConstructorDeclaration -
Deserializes a StandardConstructorDeclaration from binary format.
override