Since a longer time now it is possible to open a DynamicLibrary (dylib, dll, so) in Flutter. Those libraries are written in C or C++.
I’ve now tried to build a basic dart command line application, compiled it using
dart compile exe and tried to load it in my Flutter application using
DynamicLibrary.open(), as you would do with the native libraries in C/C++.
typedef HelloWorldFunc = Void Function(); typedef HelloWorld = void Function(); ... final dynLib = DynamicLibrary.open('/path/to/cli.exe'); final HelloWorld func = dynLib.lookup<NativeFunction<HelloWorldFunc>>('hello_world').asFunction(); func();
(I’ve followed this tutorial and just added an empty void function called hello_world
But the symbol could not be found:
Failed to lookup symbol 'hello_world': dlsym(0x7fec2310e5a0, hello_world): symbol not found
Is it generally possible to open dart-compiled libraries in Flutter, like DLLs written in C++? Since
dart compile exe generates native machine code as well
If yes, how?
Dart cannot create shared libraries like other languages can do because it needs to be run in an embedder/DartVM.
This issue has a good explanation:
Answered By – BEAGLE ENTERTAIN
Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)