Use this tag for questions about Dart's Foreign Function Interface (FFI) - the ability to call C directly from Dart. It is equally applicable to applications running in the Dart VM and to Flutter applications (except Flutter Web, of course).
Questions tagged [dart-ffi]
109 questions
0
votes
1 answer
Convert a vector of 2D array to dart/flutter for dart-ffi consumption
My c++ function is defined as follows:
std::vector, 160>> get_masks(float *img_pixels) {...}
I would request the community to help out by mapping this function to dart so it can be consumed. I even tried ffigen &…

Kanishka Munshi
- 530
- 1
- 4
- 11
0
votes
0 answers
How to build dart library libserialport for MacOS?
How do you bundle and/or deploy the dart library libserialport in MacOS?
The readme makes mention of the need to bundle and/or deploy if one is to use this library in their dart code (as opposed to flutter).
What I figured out is that I need to make…

silentCartographer
- 21
- 4
0
votes
0 answers
redirecting stdout to text or textfield in dart code
I have flutter GUI application which calls C++ DLL methods using FFI i.e. Foreign Function Interface . GUI and C++ DLL outputs some statements on console. The problem is I want to redirect those statements ( i.e. anything on stdout ) to show it on…

BND
- 51
- 12
0
votes
0 answers
Error using web-audio-api-rs and Flutter-rust-bridge : Android context was not initialized
I am trying to use the rust implementation of web audio api and call it from a flutter app.
When I try to create an AudioContext in rust and call it from flutter, I have a panic error :
E/flutter (20079):…

LucienLe
- 1
0
votes
1 answer
How to move a c++ library to Flutter executable using cmake on windows?
I'm trying to write a c++ library to extend some features for my flutter project using dart ffi. I use Cmake as the build tool for c++. On Android this works really well, because I don't need the full path to the library. But if I build my app on…

itsLeatch
- 1
- 1
0
votes
0 answers
How to Send Pointer from Native to Dart via Native Ports
I've been able to get simple strings passed from C to dart via FFI and Native Ports with on examples like:
// Basic working example on the C side
char * str = "some string";
Dart_CObject msg;
msg.type = Dart_CObject_kString;
msg.value.as_string =…

Kdigital
- 3,795
- 3
- 28
- 24
0
votes
0 answers
I am trying to call libpcap dynamic lib using dart ffi, it works fine without Flutter. However, it report "cannot open BPF device" with Flutter
I wrote a c function to call libpcap, and compile it to .dylib
#include "capture.h"
#include
#include
int run_capture(const char * dev) {
printf("start capture\n");
pcap_t* pcap;
const u_char* pkt;
struct…

Lake
- 11
- 3
0
votes
0 answers
Flutter Desktop: Get Crash Dumps
I am searching for a method to get Crash Dumps for my flutter app and store them to a local file, so they can be analyzed later. I am using the Desktop version of Flutter on Windows and Linux, and I cannot rely on having an internet connection, so…

FourtyTwo
- 1,616
- 2
- 15
- 43
0
votes
1 answer
How to get a useful error message when a dart:ffi method fails?
I have a dart method that invokes some C code using dart:ffi. When the C code fails (for example due to some memory violation), I don't get any error message to indicate what's wrong, but only the whole process exits immediately with these…

HII
- 3,420
- 1
- 14
- 35
0
votes
1 answer
Dart FFI can't load dynamic library on Android
I have a simple C++ function compiled into a dylib file that I'm trying to run on an Android phone. The function is super simple, it just adds to numbers and returns the result. However, I keep getting this error:
Another exception was thrown:…

Zachary Haslam
- 103
- 1
- 12
0
votes
0 answers
Ability to access Dart class from native code
I am in the process of migrating from Android/JNI to Flutter/Dart/FFI to build native apps. Currently in Android I have a Java class (ScanningHelper.java) which is modified during the program lifecycle. During native initialization, I send a jobject…

banerjk
- 335
- 2
- 15
0
votes
1 answer
How to create a pointer to a dart function that takes a String in dart:ffi?
I want to create binding to this C function in dart, this C function accepts a function pointer called progress_monitor:
FFI_PLUGIN_EXPORT void* magickSetProgressMonitor(..., const void* progress_monitor,...);
where progress_monitor is a function…

HII
- 3,420
- 1
- 14
- 35
0
votes
0 answers
How to convert Pointer to Uint8List in flutter
I have extracted my screenshot code from dart Win32 screenshot example (text). I have modified it a little bit to suit my case.
Here is my modified code:
Map> captureImage(int hwnd) {
final hdcScreen = GetDC(NULL); // get…

Kumah Andrews
- 1
- 2
0
votes
1 answer
How to return and correctly identify a duplicate enum from C to dart using dart ffi?
I stepped over this enum in C:
typedef enum
{
UndefinedGravity,
ForgetGravity = 0,
NorthWestGravity = 1,
NorthGravity = 2,
NorthEastGravity = 3,
WestGravity = 4,
CenterGravity = 5,
EastGravity = 6,
SouthWestGravity = 7,
…

HII
- 3,420
- 1
- 14
- 35
0
votes
1 answer
How to Link Lib.a in IOS, static as well as dynamic linking?
I have some open source c++ library , I have converted into lib.a for different IOS architecture, how can I link this library in Xcode For IOS Devices.
http://wiki.zeromq.org/build:iphone
Reference Link
The Main Target is to first test this in IOS…

wajahat akram
- 76
- 10