flutter_sodium
flutter_sodium copied to clipboard
Support for Desktop Platforms (Linux, Windows, macOS)
Interested to help. Could someone elaborate the usecase?
Well, the usecase is to simply be able to use this library for the desktop platforms, which are in beta now and will become stable soon. So, my personal usecase is to be able to develop a flutter app that needs encryption for all of the platforms.
More specificly, I found out that we already have a somewhat support for desktop: In lib/src/bindings/libsodium.dart
The library can already be loaded on the desktop platforms. However, there are two things to improve here, so we can easily use the library on desktop:
- Make the path configurable.
/usr/local/lib/libsodium.so
might work for Ubuntu, but not for other distros. And someone might want to statically link or distribute the library with the final app. So aSodium.setNativeLib("path/to/libsodium.so")
or similar would be very nice. - Distribute libsodium for desktop with the package, just like you do for Android/iOS. This should be easy for Windows and macOS but more complicated for linux. However, as long as we have Option 1, it is not really neccessary.
More specificly, I found out that we already have a somewhat support for desktop: In
lib/src/bindings/libsodium.dart
The library can already be loaded on the desktop platforms.
https://github.com/firstfloorsoftware/flutter_sodium/tree/master/lib/src/bindings is code manually or generated?
- Distribute libsodium for desktop with the package, just like you do for Android/iOS. This should be easy for Windows and macOS but more complicated for linux. However, as long as we have Option 1, it is not really neccessary.
What about the architecture of https://github.com/woodemi/quick_usb?
- Make the path configurable.
/usr/local/lib/libsodium.so
might work for Ubuntu, but not for other distros. And someone might want to statically link or distribute the library with the final app. So aSodium.setNativeLib("path/to/libsodium.so")
or similar would be very nice.
Maybe a workaround https://github.com/woodemi/quick_usb/issues/14#issuecomment-809996205 ?
If it is possible you could load the library with a relative path. I am not experience in this area. But I try to publish my app to flathub and have no access to /usr. The library is stored in /app/lib and could be found if linked dynamically.
I confirm this is a problem for flatpaks.
Can we excpect any changes to this topic? Would be nice to get an answer so we can decide to wait or find another solution. Thank you!
In lack of a better solution, I created my own sodium wrappers here: https://github.com/Skycoder42/libsodium_dart_bindings They support all platforms (mobile, desktop and web), for dart and for flutter out of the box.
I just saw that flutter_sodium actually uses a dynamic call
DynamicLibrary.open("libsodium.so.23").
But the pub.dev plugin is not updated yet.