-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dart bindings #166
base: master
Are you sure you want to change the base?
Dart bindings #166
Conversation
I noticed that the driver notifies all clients of changes, except the client that requested that change. I think this should not be the case, because this way, the client is at risk of getting out of sync, without knowing. Also this is something anyone must be aware of and introduces manual labor, since the client application now needs to keep track of its own changes. Even worse, the I think it is better when we can assume that the change events always reflect the real state of the driver and you are never at risk of getting out of sync. In fact, this fits perfectly with the state management patterns in Flutter. You often have some sort of stream that sends state changes to the UI and the UI rebuilds around the current state. When a user interaction (or else) changes the state, the Ui will not change directly, but it will rebuild in response to the stream sending a new state. virtual-display-rs/rust/virtual-display-driver/src/ipc.rs Lines 229 to 231 in 13bafda
|
I'll add a bug report and address this. Thanks for the feedback! |
Dart bindings on top of
driver_ipc
usingflutter_rust_bridge
.It uses an experimental feature, called
native_assets
, to build and link with the rust side.native_assets
introduces abuild.dart
file, similar tobuild.rs
.Dart bindings can be regenerated using
cargo make generate
.Unit tests can be run using
cargo make test
.Hack
For now it relies on a hack, because
flutter_rust_bridge
does not support linking usingnative_assets
yet.native_assets
uses@Native
annotations as follows:The
assetId
is used to identify the native library, this function should link to.flutter_rust_bridge
still uses the old way usingDynamicLibrary
, where you have to specify the full path to the native library.flutter_rust_bridge
can usually resolve the actual path. But not whennative_assets
is used, because there is no way, to get the actual path to the asset usingnative_assets
. This is deliberately abstracted away.The hack works as follows:
virtual-display-rs/rust/bindings/dart/lib/src/init.dart
Lines 6 to 19 in e774c94
When calling
frb_get_rust_content_hash
, which is linked using@Native
, dart will load the complete dll into the process. Now we can tellflutter_rust_bridge
to load its functions from the process.frb_get_rust_content_hash
is just a function that is always there influtter_rust_bridge
. It returns a constant hash value to check the version compatibility.But this can eventually be removed, when
flutter_rust_bridge
transitions to@Native
.