How celpear/flutdot works
Project type and purpose
• This is a cross-platform Flutter application (mobile: Android/iOS; desktop: Windows/macOS/Linux; web) that embeds a Godot game export (WebAssembly + HTML + JS) inside a Flutter InAppWebView.
• Its purpose is to combine Flutter’s UI and sensor-access capabilities with Godot’s 3D rendering engine, allowing bidirectional communication (e.g. passing sensor data into Godot and game events back to Flutter).
File structure
• Top-level “GoDotExport/” folder holds the Godot Web export (index.html, index.js, index.wasm, audio.worklet).
• “flutdot_godot_demo_project/” is the original Godot project source.
• “lib/” contains Flutter code:
• lib/main.dart – application entry point
• lib/module/flutdot.dart – plugin module wrapping webview + communication logic
• Platform folders (android/, ios/, macos/, linux/, windows/) contain Flutter project boilerplate and native runner code.
• “APKBuilds/” holds test APKs.
• Configuration files: pubspec.yaml, build scripts (Gradle, Xcode project files, CMake scripts for desktop).
Key insights from README
• The Godot export is loaded into a Flutter InAppWebView widget.
• Temporary communication uses JS injection + log parsing; future plan is Socket.IO/WebSocket.
• Uses Flutter packages: flutter_inappwebview, sensors_plus, axios (JS), socket.io (planned).
Main components
a. Flutter Layer
• UI widgets (Material UI)
• Sensor plugin (sensors_plus)
• InAppWebView widget
b. WebView / Godot Layer
• Godot engine compiled to WASM
• index.html + index.js loader
• Game logic scripts (DemoScene.gd, Player.gd inside WASM)
c. Communication Layer
• JS ↔ Dart bridge (evaluateJavascript, onConsoleMessage)
• Planned WebSocket/Socket.IO channel
d. Native Runners & Platform Folders
• Android (Kotlin MainActivity)
• iOS/macOS (Swift AppDelegate)
• Windows/Linux (C++ runner)
Relationships & data flows
• Sensor data (Dart) → serialize to JSON → WebView.evaluateJavascript() → Godot game engine
• Game events (JS console.log or WebSocket) → Dart onConsoleMessage or WebSocket listener → Flutter UI
• App lifecycle & platform channels (Flutter → native runner → embed WebView)
Architectural patterns & design principles
• Separation of concerns: Flutter UI vs. embedded game engine
• Plugin/module pattern: lib/module/flutdot.dart encapsulates webview + comms
• Cross-platform abstraction: a single Flutter codebase with per-platform runners
1. Sketch high-level layers (Flutter → WebView → Godot → Platform).
2. Break out sub-components (Dart modules, JS loader, WASM engine).
5. Notes on build outputs (APKBuilds, desktop binaries) and configuration (pubspec.yaml, gradle, CMake).