NativeCallable<T extends Function>.listener constructor

NativeCallable<T extends Function>.listener(
  1. @DartRepresentationOf("T") Function callback
)

Constructs a NativeCallable that can be invoked from any thread.

When the native code invokes the function nativeFunction, the arguments will be sent over a SendPort to the Isolate that created the NativeCallable, and the callback will be invoked.

The native code does not wait for a response from the callback, so only functions returning void are supported.

The callback will be invoked at some time in the future. The native caller cannot assume the callback will be run immediately. Resources passed to the callback (such as pointers to malloc'd memory, or output parameters) must be valid until the call completes.

This callback must be closed when it is no longer needed. The Isolate that created the callback will be kept alive until close is called.

Implementation

external NativeCallable.listener(
    @DartRepresentationOf("T") Function callback);