lookupFunction<T extends Function, F extends Function> method Null safety

F lookupFunction<T extends Function, F extends Function>(
  1. String symbolName,
  2. {bool isLeaf = false}
)

Looks up a native function and returns it as a Dart function.

T is the C function signature, and F is the Dart function signature.

isLeaf specifies whether the function is a leaf function. A leaf function must not run Dart code or call back into the Dart VM. Leaf calls are faster than non-leaf calls.

For example:

int32_t add(int32_t a, int32_t b) {
  return a + b;
}
DynamicLibrary dylib = DynamicLibrary.executable();
final add = dylib.lookupFunction<Int32 Function(Int32, Int32), int Function(int, int)>(
        'add');

Implementation

external F lookupFunction<T extends Function, F extends Function>(
    String symbolName,
    {bool isLeaf = false});