Epic Cash in Flutter.
Use rustup, not homebrew. Install toolchain 1.85.1.
cargo install cargo-ndkflutter run in example to run the example app
See example/lib/main.dart for usage.
This plugin uses the following structure:
rust: Contains the Rust native source code and Cargo.toml manifest for building the native library.cargokit: Cross-platform build tool that compiles Rust code for all target platforms (Android NDK, iOS/macOS, Linux, Windows).lib: Contains the Dart code that defines the API of the plugin, and which calls into the native code usingdart:ffi.- platform folders (
android,ios,windows, etc.): Contains the build files that invoke Cargokit to build and bundle the Rust library with the platform application.
Very short-running native functions can be directly invoked from any isolate.
For example, see sum in lib/epiccash.dart.
Longer-running functions should be invoked on a helper isolate to avoid
dropping frames in Flutter applications.
For example, see sumAsync in lib/epiccash.dart.
Cargokit handles building, just flutter run it or run it as you normally would on your platform.
To update Cargokit in the future, use:
git subtree pull --prefix cargokit https://github.com/cypherstack/cargokit.git main --squashcargo buildinrust/triggersbuild.rsto generateepiccash.hC headers.- To generate
epiccash.g.dartDart bindings:dart run tool/ffigen.dartin the root (may require LLVM, seeffigen's documentation.)