native library
The Rust transport, loaded from a file (Dart VM and Flutter on Android, iOS, macOS, Windows and Linux; not the web).
Apps built with Flutter or dart build cli normally use the
ws_native package instead, whose build hook bundles the library.
dart compile exe refuses to compile a program that depends on a
package with a build hook, so for those executables get the library with
dart run ws:install (again after every ws upgrade) and load it:
import 'package:ws/native.dart';
void main() {
try {
WsNativeLibrary.open('/app/lib/libws_native.so').install();
// WebSocketClient instances created from now on use it.
} on Object catch (e) {
// Missing, another architecture or another release: pure Dart.
}
}
Classes
- NativeSymbols
-
Addresses of the library's C functions (
native/rust/src/lib.rs). - NativeTransport
- The Rust transport: tokio + tungstenite + rustls, JSON parsed into a tape off the Dart thread, messages delivered in batches as external typed data (no copies), receive credits for flow control.
- WsNativeLibrary
-
The Rust library (
libws_native), loaded and checked.
Constants
- nativeAbiVersion → const int
-
Version of the C ABI this package calls; must match
ABI_VERSIONinnative/rust/src/lib.rs.