detach method

Pointer<NativeFunction<C>> detach([
  1. bool keepAlive = false
])

Removes this callback from registry, optionally disposes it, and returns its native function pointer.

The pointer is returned so it can be passed directly to the native detach API in the same call. The native side needs the pointer to identify which callback to remove, even as we're tearing it down on the Dart side:

rl.Audio.DetachAudioMixedProcessor(callback.detach());

If keepAlive is true, the callback is neither removed from registry nor disposed, only the pointer is returned. Useful when temporarily detaching without releasing resources.

Implementation

Pointer<NativeFunction<C>> detach([bool keepAlive = false]) {
  if (keepAlive) return nativeFunction;
  registry.remove(this);
  dispose();
  return nativeFunction;
}