Skip to content
pubscout

forge2d

0.15.3, released 5 weeks ago by flame-engine.org

A 2D physics engine for Dart, binding to the native Box2D v3 library.

WASM-ready
$ flutter pub add forge2d
Source repository

What it does

Provides an idiomatic Dart API for the native Box2D v3 physics engine. Supports simulations running at native speed via FFI across multiple platforms, and also works with the Flame game engine.

AI-written summary of version 0.15.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a 2D game in Dart or Flutter requiring rigid body physics.
  • You are using the Flame game engine and need advanced 2D collision detection and gravity.

Skip it when

  • You are building standard business apps or UIs that do not require physics simulations.
  • You cannot include a native C toolchain for compilation on target desktop/mobile platforms.

Strengths

  • High performance via native Box2D v3 bindings and WebAssembly on the web.
  • Integrates seamlessly with the Flame game engine.

Weaknesses

  • Requires a C toolchain on native platforms (Xcode, Visual Studio, gcc/clang, NDK).
  • Breaking changes from older versions require manual migration.

Setup

Kind
FFI (native library)
Effort
Medium
Code generation
No
Direct dependencies
7

Requires a C toolchain on native platforms (Xcode, Visual Studio, clang/gcc, NDK) and calling await initializeForge2D() at startup.

import 'package:forge2d/forge2d.dart';

Future<void> main() async {
  await initializeForge2D();
  final world = World();
  world.createBody(BodyDef(position: Vector2(0, -1))).createShape(Polygon.box(50, 1));
  world.destroy();
}

Alternatives

Packages that do the same job and could replace forge2d.

  • flame

    If you want a complete game engine ecosystem rather than a standalone physics library.

Works with

Packages commonly used together with forge2d: ones it builds on, ones built on it, and its own family.