Xcelerate Dart / Flutter SDK
Note: the early
uniffi-bindgen-dart0.1.x generator has several codegen bugs for this API.scripts/generate_bindings/dart.pypost-processes the output before it is written; see_patch()in that script. The fixes are:
- async
boolreturns and the async constructor are emitted synchronously;Browser::close/Page::closecollide with the disposer (renamedcloseBrowser/closePage);- the
Browser.launchasync constructor (aRustBufferargument) is stubbed withUnsupportedError, so the whole binding is unusable - it is implemented directly;- error payloads are dropped ("extra bytes remaining") - decoded here;
Vec<u8>returns keep their UniFFI length prefix - stripped here;- the FFI helper symbols use an
uniffi_-prefixed library name; the generator is invoked with--crate xcelerateso they match the exported symbols.Re-check every fix when bumping the generator.
Dart bindings for the xcelerate Rust CDP engine. Dart is not a built-in UniFFI
target, so the sources are generated with the external
uniffi-bindgen-dart generator
(pinned to a release that targets UniFFI 0.31).
Requirements
- Dart SDK 3.1+ or Flutter
- The
uniffi-bindgen-dartgenerator:cargo install uniffi-bindgen-dart - The native xcelerate library, shipped as
xcelerate.dll/libxcelerate.so/libxcelerate.dylib(copied by the script). It must be built with UniFFI'sscaffolding-ffi-buffer-fnsfeature (enabled in the workspaceCargo.toml), which exports theuniffi_ffibuffer_*entry points this binding calls.
Generate / build
# from the repository root
cargo install uniffi-bindgen-dart # once
python scripts/generate_bindings/dart.py
The script assembles a pub package:
bindings/dart/
pubspec.yaml
lib/xcelerate.dart
src/xcelerate.dll / libxcelerate.so / libxcelerate.dylib # local only
or, once generated, inside this directory:
dart pub get
dart analyze
Usage
The generated binding loads the native library by name (xcelerate); pass
libraryPath when the loader cannot find it:
import 'package:xcelerate/xcelerate.dart';
final config = BrowserConfig(
headless: true,
detached: true,
executablePath: null, // auto-discover Chrome/Edge
plugins: ['stealth', 'human'], // opt into built-in plugins
);
final browser = await Browser.launch(config);
final page = await browser.newPage('https://example.com');
print(await page.title());
await browser.closeBrowser(); // `close` is reserved by the disposer
Plugins load from disk sandboxed (WebAssembly) behind the capability gate;
loadPlugin instantiates the entrypoint component the manifest names.
Publishing
python scripts/publish/dart.py # regenerate + `dart pub publish --dry-run`
python scripts/publish/dart.py --push # `dart pub publish --force`
dart pub publish authenticates with a Google account (OAuth on first run) or a
PUB_TOKEN in CI. The published package is source-only: the native library
is platform-specific, so it is not bundled in the pub package - bundle it with
your app and pass libraryPath (or place it where DynamicLibrary.open finds
it). The generator still copies the host library under src/ for local runs.
License
Licensed under either of Apache-2.0 or MIT, at your option.