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
1
vote
1 answer
Flutter: Dart FFI can't find symbol
I have included libavcodec.dylib in a Flutter project following the standard Flutter FFI instructions.
Calling DynamicLibrary.open('libavcodec.59.dylib') executes without issue, and returns a non-negative handle address, which (I think) indicates a…

SuperDeclarative
- 311
- 1
- 8
1
vote
0 answers
who to load .SO library in flutter project
I'm trying to link in a pre-compiled shared library file called librandomnumber.so in my project.
code for CMakeLists.txt:
link_directories('lib/native_Library/librandomnumber.so')
add_library(native-lib…

pub Dart
- 19
- 3
1
vote
0 answers
Flutter, get image as data back from c++ opencv
I am really new to Flutter and C++. So I am struggling with this one. I want to do some transformation to an image through ffi->c++ (opencv). Here's my code on the Flutter side:
class Processvalue extends Struct {
Pointer image;
factory…

pewpewlasers
- 3,025
- 4
- 31
- 58
1
vote
1 answer
How to pass a list of strings to C In dart ffi
I'm learning how to use dart ffi.
I don't have much C experience or knowledge.
I'm trying to call a function from a C library(tiny file dialogs).
I can call other functions however I can't call this one
char * tinyfd_saveFileDialog(
char…

xerotolerant
- 1,955
- 4
- 21
- 39
1
vote
0 answers
adding static library to iOS
I want to add a static library to iOS.
first of all, I added some_library.a file to ios/lib directory, then I add vendored_libraries to .podspec file like this:
...
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES',…

Hamed
- 5,867
- 4
- 32
- 56
1
vote
1 answer
ffi Utf8.fromUtf8 error while implementing opencv c++ flutter app on iOS
I am using opencv and flutter for building an app. ffi package is used to implement a bridge and I got error from a tutorial code. I could not find any solution. Could you please kindly help me? I got error when Utf8.fromutf8 and Utf8.toUtf8
import…

Muhtar
- 1,506
- 1
- 8
- 33
1
vote
1 answer
Why does Dart FFI generate an opaque class from this C struct?
I want to use the MAVLink C library to parse MAVLink packets in dart, but the Dart FFI generated mavlink_message_t is an opaque class, while other structs like mavlink_system_t are generated normally with all their attributes. What is the reason for…

alielbashir
- 315
- 2
- 9
1
vote
0 answers
Dart FFI vs Java library linking
It's unclear how Dart VM loads a C/C++ library through FFI.
final dylib = ffi.DynamicLibrary.open(libraryPath);
Some C++ libraries require a java context to work on Android. For example, Juce library is initialized through
public class Java
{
…

PPP
- 1,279
- 1
- 28
- 71
1
vote
1 answer
Flutter-Desktop sqflite ffi throwing error on release mode
I am using sqflite ffi for my database on desktop windows.
I setup everything like in the sample. The application is working on debug built but if I run the application on release mode I'm getting the error in sqfliteFfiInit(). How can I fix…

quoci
- 2,940
- 1
- 9
- 21
1
vote
1 answer
Dart / Flutter ffi on linux - Problem to configure CMake
I currently need to call a C++ function in my Flutter project, for a Linux desktop application (using dart:ffi). This page https://flutter.dev/docs/development/platform-integration/c-interop#first-party-library doesn't explain how to configure this…

Philiste
- 161
- 13
1
vote
1 answer
How to access methods in a Flutter for desktop (macOS) app
I have been trying to write a Flutter desktop app which can communicate with Go methods.
Go file:
package main
import "C"
import "fmt"
func PrintHello() {
fmt.Print("Hello,World")
}
func main() {}
import 'dart:ffi' as ffi;
typedef…

Ganesh Rathinavel
- 1,243
- 4
- 17
- 38
1
vote
2 answers
Passing big arrays efficiently between Flutter (dart) and its FFI (C/C++)?
We are developing a "image editor" app using Flutter. Thus, we need to (1) show images on the UI, and (2) manipulate images using some algorithms in C/C++.
Flutter does have a FFI between dart and c/c++, but I do not know how to pass big arrays like…

ch271828n
- 15,854
- 5
- 53
- 88
0
votes
0 answers
Loading pre-compiled GStreamer dynamic library for use with Dart FFI fails
I'm trying to create a Dart FFI plugin for the GStreamer library to use it in my Flutter application on Windows, with plans to expand to other platforms in the future. Since GStreamer is written in C, I thought it would be relatively straightforward…

NattyPluz
- 26
- 3
0
votes
0 answers
I'm using FFI library to connect a DLL with a Flutter desktop application, but getting: "Failed to load dynamic library"
//random_number.c:
#include
#include
#include
#include "randomnumber.h"
int main()
{
int number = fetch_number();
printf("Random number: %d\n", number);
return 0;
}
int fetch_number()
{
int c, n;
…
0
votes
2 answers
How to convert dart:ffi Char to String
I have a dart:ffi Struct that contains a pointer to a Char and int len
class UnnamedStruct1 extends ffi.Struct {
external ffi.Pointer ptr;
@ffi.Int()
external int len;
}
it is supposed to represent a String (later to parse as…

Francesco Iapicca
- 2,618
- 5
- 40
- 85