GenericConstructorConfig class

Configuration for a templated RC-2 generic constructor factory.

Reifies a script's explicit type argument (GlobalKey<NavigatorState>(), ValueKey<String>('k')) into a concrete native generic, which the interpreter's type-erased constructor boundary otherwise can't do (R3). The generator emits a D4.registerGenericConstructor(className, '', …) whose body is a switch (typeName) over typeArgVariants; the body shape is selected by kind.

Dormant by default (BridgeConfig.genericConstructors is empty), so until a buildkit.yaml declares one the generated registerGenericConstructors() is byte-identical.

YAML form:

d4rtgen:
  genericConstructors:
    - className: GlobalKey
      kind: namedPassthrough
      namedArgs:
        - name: debugLabel
          type: String
      typeArgVariants: [NavigatorState, FormState, ScaffoldState]
    - className: ValueNotifier
      kind: nullableValue
      includeDynamicArm: true
      typeArgVariants: [String, int, double, bool]

Constructors

GenericConstructorConfig({required String className, required GenericConstructorKind kind, List<String> typeArgVariants = const [], List<GenericCtorNamedArg> namedArgs = const [], bool includeDynamicArm = false})
const
GenericConstructorConfig.fromJson(Map<String, dynamic> json)
factory
GenericConstructorConfig.fromYaml(Object value)
factory

Properties

className String
The bridged class whose generic constructor is reified (e.g. GlobalKey).
final
hashCode int
The hash code for this object.
no setterinherited
includeDynamicArm bool
Whether to prepend the 'dynamic' || 'Object' || 'Object?' arm mapping to Class<dynamic>(value). Used only by GenericConstructorKind.nullableValue (true for ValueNotifier, false for ValueKey).
final
kind GenericConstructorKind
Which body shape to emit (see GenericConstructorKind).
final
namedArgs List<GenericCtorNamedArg>
The named arguments forwarded to every arm. Used only by GenericConstructorKind.namedPassthrough; empty for nullableValue.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
typeArgVariants List<String>
The allow-list of concrete type-arg names, in switch order. For GenericConstructorKind.namedPassthrough these are the reified subtypes (NavigatorState); for GenericConstructorKind.nullableValue the value types (String, int).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
inherited

Operators

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