raylib_dartified_web 5.5.0
raylib_dartified_web: ^5.5.0 copied to clipboard
Web (WASM) backend for raylib_dartified.
Raylib for Dart (WASM) #
A Dart-first, modular WASM binding for raylib via Emscripten.
⚠️ Stability warning
You should not rely on regular git pulls or updates to be non-breaking. If you use this project, consider vendoring or pinning a specific commit.
The API is not stabilized. Method signatures, type names, and module boundaries are subject to change without deprecation cycles. This applies especially to the
D(Dart) layer, which is newer and less battle-tested than the raw WASM bindings.In particular, the
D(Dart) layer may still contain undetected memory safety issues - incorrect struct serialization, ownership ambiguity, or linear memory misuse that has not yet surfaced. The fact that all provided examples run correctly is not proof that theDlayer is safe or correct in general. If you are doing anything non-trivial, audit the relevantDwrappers before trusting them.
This project exposes raylib in an idiomatic Dart API targeting the browser via WebAssembly. Raylib is compiled with Emscripten and bridged to Dart through JS interop and a shared linear memory interface.

Platform Support #
Web only. Requires a browser with WebAssembly and WebGL support, all modern browsers SHOULD qualify.
For native platforms (Linux, Windows, etc.), see
raylib_dartified.
Build #
Note: The build tooling is functional but currently limited, not all emcc/cmake options are configurable yet. If you need custom flags, you'll need to invoke the toolchain manually for now.
Prerequisites #
- Emscripten (emsdk) installed and sourced
git,cmake, anddarton your PATH
First-time setup #
Downloads and builds raylib + raygui for WASM via emscripten:
dart run raylib_dartified_web:setup
This only needs to run once.
Building your project #
dart run raylib_dartified_web:build --entry=lib/main.dart
Output is written to build/ in your current directory.
Options:
| Flag | Description |
|---|---|
--entry |
(required) Path to your Dart entry file |
--raylib-c |
Custom raylib.c (default: package builtin) |
--raylib-func-list |
Custom exported functions list (default: package builtin) |
--raylib-resources |
Path to resources/ directory to preload (default: ./resources) |
Recommended Starting Point #
See any example in example/<category>/.
Or start here: core/core_basic_window.dart
abbr.dart #
Since only one Raylib instance is allowed at a time, abbr.dart lets you skip one layer of namespacing and save some keystrokes. The Raylib instance remains accessible via Raylib.instance:
import 'package:raylib_dartified_web/raylib.dart';
import 'package:raylib_dartified_web/abbr.dart';
void main() => Raylib((rl) {
CoreD.InitWindow(800, 600, 'Title');
});
Safety Notes #
- You are responsible for correct usage when writing into or reading from WASM linear memory directly
- Passing invalid offsets or malformed structs will produce undefined behavior or crashes
Guiand other optional modules will be uninitialized if not loaded- The
Dwrappers handle most of this for you - use them if in doubt
If you want guardrails, build them on top of this layer - or just use the D API.
Examples #
This repository includes ported raylib examples, rewritten to use the Dart WASM API exposed here.
The examples closely follow the original raylib examples, making it easy to cross-reference C code with Dart usage.
These examples are the recommended starting point to understand real-world usage, correct memory handling, and idiomatic patterns for this binding.
See the example/ directory for runnable code.
WARNING: Some examples require
resources/from the original Raylib source.
In that case just copy-paste theresources/folder into your project folder or provide--raylib-resources=<path>option to theraylib_dartified_web:buildutility.
See Also #
License #
This project is released under the zlib/libpng license.
It contains bindings and rewritten components derived from raylib, which is also licensed under zlib.
See LICENSE for details.
Acknowledgements #
- raylib by Ramon Santamaria
- Dart & Emscripten
PRs, issues, and experiments are welcome.