3 ms·
I successfully used Rust to create a shared library in a Flutter project that works on both iOS and Android. So far I've only published the iOS app: https://app
by asymptotic 6y ago
I successfully used Rust to create a shared library in a Flutter project that works on both iOS and Android. So far I've only published the iOS app: https://apps.apple.com/us/app/ezmempass/id1490538369 https://apps.apple.com/us/app/ezmempass/id1490538369
I heavily relied on the following blog post: https://dev.to/robertohuertasm/rust-once-and-share-it-with-android-ios-and-flutter-286o https://dev.to/robertohuertasm/rust-once-and-share-it-with-a...
Overall it's painful to set up and requires knowledge of the native platform (XCode/Swift, Android Studio/NDK/Kotlin), but overall it works and it was fun getting it working.
I'm happy to answer more questions about it, I've been meaning to write up the experience and details.
- boustrophedon 6y agoI think it should become easier to do this once the Dart ffi module becomes stable. https://dart.dev/guides/libraries/c-interop https://dart.dev/guides/libraries/c-interop
- nmfisher 6y agoI recently did something similar (though I haven't had a chance to clean up or document the repositories for Flutter plugin/Rust library yet). The Flutter application uses FFI to invoke the Rust library, passing a series of strokes (i.e. coordinates on a 2D canvas) and returning a list of Chinese character candidates. Although it's not yet stable, I was very impressed with Dart FFI. I've used both JNI and .NET PInvoke for native interop before, and Dart FFI was probably the easiest (PInvoke is fine, but JNI is horrible). https://github.com/nmfisher/flutter_chinese_character_recognition https://github.com/nmfisher/flutter_chinese_character_recogn... https://github.com/nmfisher/hanzi_lookup https://github.com/nmfisher/hanzi_lookup (forked from the original https://github.com/gugray/hanzi_lookup https://github.com/gugray/hanzi_lookup)