Fundamentals (v2)
dart_cpp_bridge is a Dart ↔ C++20 bridge inspired by
Flutter Rust Bridge. Business code
is written as ordinary C++ functions or stdexec::task<T> / sender pipelines;
the bridge handles codec, scheduling, lifecycle, and Dart API generation.
Core capabilities
Section titled “Core capabilities”- Sync —
BRIDGE_SYNCreturns a value directly. - Async —
BRIDGE_ASYNCreturnsFuture<T>from astdexec::task<T>or supported sender. - Normal —
BRIDGE_NORMALruns blocking work on the thread pool. - Streams —
StreamSink<T>produces DartStream<T>. - DartFn — C++ can suspend while awaiting a Dart closure reply.
- Channels —
co::oneshotandco::mpscconnect workers and coroutines. - Opaque/data classes — generated handles and value codecs.
- Cross-runtime scheduling — foreign event loops provide plain stdexec schedulers.
Current stack
Section titled “Current stack”| Layer | Technology |
|---|---|
| C++ | C++20 |
| Async model | stdexec senders / stdexec::task |
| Built-in event loop | Asio io_context, one io runner by default |
| Blocking work | Asio thread pool |
| Cancellation | stop tokens |
| Codegen | Python 3.13 + libclang-ng, pinned and hash-verified |
| Build | CMake 3.25+ and Native Assets hooks |
Read next
Section titled “Read next”- Versioned Documentation — choose v1 or v2
- Getting Started — create a project
- Architecture — call flow
- Choosing a Marker — select sync, async, normal, or stream
- v2 stdexec Async C++ — sender and task rules
- Channels — oneshot, mpsc, backpressure, and cancellation
- Threading and Blocking Work — pool sizing and custom schedulers
- Built-in Runtime — Runtime and scheduler
- Lifecycle Management — sessions and finalizers
- Native Assets Build Hooks — native build integration