RuntimeHint constructor

const RuntimeHint({
  1. required Type type,
  2. NewInstanceCreator? newInstance,
  3. InvokeMethodCreator? invokeMethod,
  4. GetValueCreator? getValue,
  5. SetValueCreator? setValue,
})

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;
  },
);

Implementation

const RuntimeHint({required this.type, this.newInstance, this.invokeMethod, this.getValue, this.setValue});