Skip to main content

Using the dynamic library

info

This guide was written for flutter_rust_bridge v1, thus some content may be outdated. The quickest approach to integrate is to follow the one-click approach in flutter_rust_bridge's quickstart page.

If everything went well, running flutter run will now build your Rust library, the Flutter binary and link the two together. Now the only thing left to do is to actually use it!

Download this file to lib/ffi.dart, then modify its contents:

 // Re-export the bridge so it is only necessary to import this file.
export 'bridge_generated.dart';
import 'dart:io' as io;

-const _base = 'native';
+const _base = '$crate';

// On MacOS, the dynamic library is not bundled with the binary,
// but rather directly **linked** against the binary.
final _dylib = io.Platform.isWindows ? '$_base.dll' : 'lib$_base.so';