$ show fuzzybinary/godot_dart
This repository provides a bridge between the Dart programming language and the Godot 4.2+ game engine via the GDExtension interface. It enables developers to write game logic in Dart, treating Dart classes as Godot scripts or extensions. The system consists of a C++ GDExtension module that loads the Dart VM and sets up bindings, a Dart core library with annotations and type marshaling, code generation tools for creating bindings, and example projects demonstrating usage. Key features include signal handling, property system integration, and hot-reload support via editor plugins. While the project shows active maintenance and thoughtful engineering patterns, it has some complexity in setup and relies on external code generation.
The LLM identified 2 files worth highlighting for reuse:
Provides typed signal classes (Signal0-Signal5) with emit() and asFuture() methods, enabling idiomatic Dart async/await patterns for Godot signals. This component is self-contained (depends only on core Dart), demonstrates a clean abstraction for event handling, and could be reused in any event-driven system with minimal modification.
Exemplifies the CopyiedBuiltinType pattern for managing native struct lifecycle in FFI interactions. This base class handles allocation and cleanup of native memory to prevent leaks, a non-obvious but critical skill in Dart-C++ interop. The pattern is isolated (used across vector3, basis, etc.) and could be extracted for any Dart FFI scenario involving structs with manual memory management.