RuntimeHint class

A hint that defines how to interact with a specific type Object through reflection-like operations.

RuntimeHint is a metadata container used by JetLeaf's reflection system, especially in environments without dart:mirrors, such as ahead-of-time (AOT) compilation.

It provides function references to:

  • Create new instances of Object
  • Invoke methods on Object
  • Read fields on Object
  • Write fields on Object

These operations are usually supplied by generated code or runtime hooks.

Example

final descriptor = RuntimeHint(
  type: MyClass,
  newInstance: (name, [args = const [], namedArgs = const {}]) => MyClass(),
  invokeMethod: (instance, method, {args = const [], namedArgs = const {}}) {
    if (method == 'sayHello') return instance.sayHello();
    throw UnimplementedError();
  },
  getValue: (instance, name) {
    if (name == 'value') return instance.value;
    throw UnimplementedError();
  },
  setValue: (instance, name, value) {
    if (name == 'value') instance.value = value;
  },
);

Constructors

RuntimeHint({required Type type, NewInstanceCreator? newInstance, InvokeMethodCreator? invokeMethod, GetValueCreator? getValue, SetValueCreator? setValue})
A hint that defines how to interact with a specific type Object through reflection-like operations.
const

Properties

getValue GetValueCreator?
Function to get the value of a field on an instance of type Object.
final
hashCode int
The hash code for this object.
no setterinherited
invokeMethod InvokeMethodCreator?
Function to invoke a method on an instance of type Object.
final
newInstance NewInstanceCreator?
Function to create a new instance of type Object.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
setValue SetValueCreator?
Function to set the value of a field on an instance of type Object.
final
type Type
The runtime type this descriptor applies to.
final

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