Skip to content

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.

  • SyncBRIDGE_SYNC returns a value directly.
  • AsyncBRIDGE_ASYNC returns Future<T> from a stdexec::task<T> or supported sender.
  • NormalBRIDGE_NORMAL runs blocking work on the thread pool.
  • StreamsStreamSink<T> produces Dart Stream<T>.
  • DartFn — C++ can suspend while awaiting a Dart closure reply.
  • Channelsco::oneshot and co::mpsc connect workers and coroutines.
  • Opaque/data classes — generated handles and value codecs.
  • Cross-runtime scheduling — foreign event loops provide plain stdexec schedulers.
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