Hello I am using dart:ffi to build an interface with my native c/c++ library. and I needed a way to get a callback from c to dart as an example in sqlite:
int sqlite3_exec(
sqlite3*, /* An open database */
const char *sql, /* SQL to be evaluated */
int (*callback)(void*,int,char**,char**), /* Callback function */
void *, /* 1st argument to callback */
char **errmsg /* Error msg written here */
);
the third parameter in sqlite3_exec
is function pointer to a callback.
so if I called this function in dart using ffi
I need to pass a function pointer: and in dart:ffi
Pointer
class there is a function named fromFunction
witch accepts a dart static function and an exceptionalReturn
; but just by calling this function to get the function pointer of a dart managed function: a (sigterm)
is raised and the dart code no long work in the process.
So My Question: Is there any way to get a native callback in dart, as in Python, c#, ..
Extra:
Is there any way to include dartino
in a flutter
project, since this ForeignDartFunction covers what I need.
Pointer.fromFunction
? api.dart.dev/stable/2.8.1/dart-ffi/Pointer/fromFunction.html – FullbackfromFunction
. – Stooge