CallbackD<C extends Function, D extends Function> class abstract

A Dart-side wrapper around a NativeCallable<C>, bridging a Dart function of type D to a native callback of type C.

Subclasses define the actual function and registry they belong to. Each concrete callback type (e.g. AudioCallbackD) owns a static registry that tracks all live instances, enabling bulk disposal via disposeRegistry.

Initialization of the underlying NativeCallable is deferred to the first access of nativeFunction rather than the constructor, to avoid preventing proper dispose calls on app exit.

Typical usage:

final cb = AudioCallbackD.function((buffer, frames) { ... });
rl.Audio.AttachAudioMixedProcessor(cb); // calls attach() internally
// ...
rl.Audio.DetachAudioMixedProcessor(cb); // calls detach() internally, disposes cb
Implementers

Constructors

CallbackD([String? name])

Properties

function → D
The Dart function exposed to the native side.
no setter
hashCode int
The hash code for this object.
no setterinherited
name String
A human-readable name for this callback, used in toString and logging.
getter/setter pair
nativeFunction Pointer<NativeFunction<C>>
Returns the native function pointer for this callback.
no setter
registry List<CallbackD<Function, Function>>
The registry of live callbacks for this callback type.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

attach() Pointer<NativeFunction<C>>
Registers this callback and returns its native function pointer.
detach([bool keepAlive = false]) Pointer<NativeFunction<C>>
Removes this callback from registry, optionally disposes it, and returns its native function pointer.
dispose() → void
Closes the underlying NativeCallable and marks this instance as disposed.
initializer() NativeCallable<C>
Creates and returns the NativeCallable<C> wrapping function.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns name.
override

Operators

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

Static Methods

disposeRegistry(List<CallbackD<Function, Function>> registry) → void
Disposes all callbacks in registry and clears it.