Step 3: Load the code using the FFI library

In this example, you can add the following code to
lib/native_add.dart. However the location of the
Dart binding code isn’t important.

First, you must create a DynamicLibrary handle to
the native code.

import

'dart:ffi'

// For FFI

final

DynamicLibrary

nativeAddLib

DynamicLibrary

process

();

With a handle to the enclosing library,
you can resolve the native_add symbol:

Finally, you can call it. To demonstrate this within
the auto-generated “example” app (example/lib/main.dart):

Other use cases

iOS and macOS