My c++ function is defined as follows:
std::vector<std::array<std::array<float, 160>, 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 & Chatgpt but the results were unsatisfactory.
Also is there any good resource from where I can learn this concept?
Solution:
You can use this code as a start, BUT DON'T FORGET TO FREE THE ALLOCATED MEMORY (AND EVEN OPTIMIZE IT MORE TO YOUR SPECIFIC CASE, AS IT MAY NOT BE OPTIMIZED AND IT IS JUST FOR DEMONSTRATION):
Result:
Sample App: Full working example steps:
flutter create --template=plugin_ffi --platforms=android,ios,windows,macos,linux sample_ffi_pluginsample_ffi_plugin.cinsrc/tosample_ffi_plugin.cpp(and rename it also inCMakeLists.txtsample_ffi_plugin.cppwith these:sample_ffi_plugin.hwith these:sample_ffi_plugin.dartin/lib/with this:/exampleand replacemain.dartwith this: