Game Framework

What is Game Framework?

Game Framework is a unified, modular framework for embedding multiple game engines (Unity, Unreal Engine) into Flutter applications. It provides a consistent API, bidirectional communication, and complete lifecycle management across all supported engines and platforms.

The Problem We Solve

The Challenge of Game Engine Integration

Integrating game engines like Unity or Unreal Engine into Flutter applications is traditionally complex:

  • Engine-Specific Code - Different APIs for each engine
  • Platform Complexity - Different integration methods for iOS, Android, desktop
  • Communication Barriers - No standardized way to communicate between Flutter and engines
  • Lifecycle Management - Manual handling of pause, resume, and destroy events
  • Build Complexity - Manual export and sync processes for each platform

The Game Framework Solution

Game Framework solves these challenges by providing:

  1. Unified API - Single interface that works with all game engines
  2. Platform Abstraction - Automatic handling of platform-specific details
  3. Bidirectional Communication - Type-safe messaging with high performance
  4. Lifecycle Management - Automatic pause/resume/destroy handling
  5. Automated Tooling - CLI tools for exports, builds, and deployment

How Game Framework Works

graph TB
    subgraph FlutterApp[Flutter Application]
        GameWidget[GameWidget]
        Controller[GameEngineController]
    end
    
    subgraph SDK[Game Framework SDK]
        CoreAPI[Core API]
        UnityPlugin[Unity Plugin]
        UnrealPlugin[Unreal Plugin]
    end
    
    subgraph NativeBridge[Native Bridge]
        AndroidBridge[Android Bridge]
        iOSBridge[iOS Bridge]
        DesktopBridge[Desktop Bridge]
    end
    
    subgraph GameEngines[Game Engines]
        Unity[Unity Engine]
        Unreal[Unreal Engine]
    end
    
    GameWidget --> Controller
    Controller --> CoreAPI
    CoreAPI --> UnityPlugin
    CoreAPI --> UnrealPlugin
    UnityPlugin --> AndroidBridge
    UnityPlugin --> iOSBridge
    UnrealPlugin --> AndroidBridge
    UnrealPlugin --> iOSBridge
    AndroidBridge --> Unity
    iOSBridge --> Unity
    AndroidBridge --> Unreal
    iOSBridge --> Unreal

Architecture Overview

Game Framework consists of three main layers:

1. Core Framework Layer

The gameframework package provides:

  • GameWidget - Universal widget for embedding any engine
  • GameEngineController - Unified controller for engine lifecycle and communication
  • GameEngineRegistry - Plugin registration system
  • Platform interfaces for Android, iOS, macOS, Windows, Linux

2. Engine Plugin Layer

Separate packages for each engine:

  • gameframework_unity - Unity Engine integration
  • gameframework_unreal - Unreal Engine integration

Each plugin implements:

  • Engine-specific controller
  • Platform view integration
  • Message protocol adapters
  • Native bridge implementations

3. CLI Tool Layer

The game-cli command-line tool provides:

  • Automated game exports from Unity/Unreal
  • File synchronization to Flutter project
  • Build automation
  • Cloud publishing
  • Workspace management

Core Concepts

GameWidget

The GameWidget is the main UI component for displaying game engines in Flutter:

GameWidget(
  engineType: GameEngineType.unity,
  config: GameEngineConfig(
    runImmediately: true,
    fullscreen: false,
  ),
  onEngineCreated: (controller) {
    // Engine is ready
  },
  onMessage: (message) {
    // Received message from engine
  },
)

GameEngineController

The controller manages the engine lifecycle and communication:

// Send messages to the game
controller.sendMessage('GameManager', 'LoadLevel', 'Level1');

// Pause the engine
controller.pause();

// Resume the engine
controller.resume();

// Dispose the engine
controller.dispose();

Communication Protocol

Game Framework supports multiple communication protocols:

  • String Messages - Simple text-based messaging
  • JSON Messages - Structured data with automatic serialization
  • Binary Protocol - High-performance binary messaging for large data

Lifecycle Management

Automatic handling of application lifecycle events:

  • Created - Engine initialized and ready
  • Paused - App goes to background
  • Resumed - App returns to foreground
  • Disposed - Engine cleaned up and destroyed

Platform Support

PlatformgameframeworkUnityUnrealStatus
AndroidStable
iOSStable
macOSBeta
WindowsBeta
LinuxBeta

Use Cases

Mobile Games with Native UI

Build mobile games that combine game engine 3D content with Flutter's native UI:

  • Challenge: Game engines provide limited UI capabilities
  • Solution: Use Flutter for menus, HUD, settings while game engine handles 3D gameplay
  • Result: Native-looking UI with powerful 3D game content

AR/VR Experiences

Create augmented reality experiences with Flutter UI overlays:

  • Challenge: Need native mobile UI with AR content
  • Solution: Combine Unity AR Foundation with Flutter UI
  • Result: Professional AR apps with Flutter's UI framework

3D Product Visualizers

Add interactive 3D product visualization to e-commerce apps:

  • Challenge: Need high-quality 3D rendering in Flutter apps
  • Solution: Embed Unity/Unreal 3D viewer with Flutter checkout flow
  • Result: Rich 3D experiences in production Flutter apps

Interactive Learning Apps

Build educational apps with 3D interactive content:

  • Challenge: Complex 3D simulations in educational apps
  • Solution: Use game engine for simulations, Flutter for lessons and UI
  • Result: Engaging educational experiences

Technology Stack

Game Framework is built with modern, production-ready technologies:

SDK

  • Language: Dart 3.0+
  • Framework: Flutter 3.3+
  • Architecture: Platform channels with native bridges
  • Communication: MethodChannel with binary codecs

CLI

  • Language: Dart 3.0+
  • Build System: Native compilation with dart compile
  • Authentication: OIDC with device flow (RFC 8628)
  • Package Management: Automated tar.gz creation and upload

Native Bridges

  • Android: Kotlin with Unity/Unreal native libraries
  • iOS: Swift with framework embedding
  • Desktop: C++ platform implementations

Getting Started

Ready to integrate game engines into your Flutter app?

Open Source & Community

Game Framework is open source and actively developed:

  • License: MIT License
  • Repository: GitHub (xraph/gameframework)
  • Issues: GitHub Issues for bug reports and features
  • Discussions: GitHub Discussions for questions and ideas

Join our growing community of Flutter and game developers building amazing integrated experiences!