Hey again! Back with another pass at fixing up the native glue code. I recently needed to run our app on a Linux machine and encountered a crash with flutter_zxing whenever it called encodeBarcode. With this PR, I can now confidently run flutter_zxing on Linux w/o issues!
Overview
This PR:
Adds support for Linux (minus camera support, of course). Had to fix some SEGFAULTs in the native code to get this working.
Adds an integration test exercising the FFI code.
Adds flutter build and flutter test integration_test Github CI workflows running across android, iOS, macOS, and linux. Windows build fails to compile though.
Enforces strict allocator discipline in the native code. Memory freed in C++ from Dart must use dart_free. Memory freed in Dart from C++ must be allocated with dart_malloc.
Tries hard to ensure we don't throw/unwind exceptions across the FFI boundary, which is unsafe. Public FFI functions are marked noexcept.
Hey again! Back with another pass at fixing up the native glue code. I recently needed to run our app on a Linux machine and encountered a crash with
flutter_zxing
whenever it calledencodeBarcode
. With this PR, I can now confidently runflutter_zxing
on Linux w/o issues!Overview
This PR:
flutter build
andflutter test integration_test
Github CI workflows running across android, iOS, macOS, and linux. Windows build fails to compile though.dart_free
. Memory freed in Dart from C++ must be allocated withdart_malloc
.noexcept
.I recommend reviewing by commit.