box2d 0.4.0

  • Installing
  • Versions
  • 85

###A Dart 2D physics engine

Build Status Coverage Status

This is a Dart port of Java's Box2D libraries.

The Java Box2D library was originally written by Daniel Murphy (status February 2015).

benchmark/bench2d.dart   Benchmark used by Joel Webber
example/index.html       Browser demos as written by Dominic Hamon
lib/                     Port of Daniel Murphy's jbox2d

First Dart port of an earlier version of Box2D library was done by Dominic Hamon. We are grateful for his work.

Not an official Google project


  • Breaking: Made package strong-mode compliant (with implicit-casts and implicit-dynamic off). This means many API points are now more strongly typed (num is now double). Fix errors by providing doubles where they are expected (1 will become 1.0 and num fraction = .5 will become double fraction = .5), and explicitly casting joints (world.createJoint(jointDef) as RevoluteJoint).
  • Pulled in optimizations and bug fixes from the original jbox2d project.
  • Made velocityThreshold mutable (as per jbox2d and other box2d implementations).


  • Updated to vector_math 2.0.0


  • Complete re-write. Many APIs have changed.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  box2d: "^0.4.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:box2d/box2d.dart';
Version Uploaded Documentation Archive
0.4.0 Dec 14, 2017 Go to the documentation of box2d 0.4.0 Download box2d 0.4.0 archive
0.3.0 May 9, 2016 Go to the documentation of box2d 0.3.0 Download box2d 0.3.0 archive
0.2.0 May 11, 2015 Go to the documentation of box2d 0.2.0 Download box2d 0.2.0 archive
0.1.7 Jul 9, 2013 Go to the documentation of box2d 0.1.7 Download box2d 0.1.7 archive
0.1.6 Jun 5, 2013 Go to the documentation of box2d 0.1.6 Download box2d 0.1.6 archive
0.1.5 Jun 4, 2013 Go to the documentation of box2d 0.1.5 Download box2d 0.1.5 archive
0.1.4 Apr 9, 2013 Go to the documentation of box2d 0.1.4 Download box2d 0.1.4 archive
0.1.3 Apr 3, 2013 Go to the documentation of box2d 0.1.3 Download box2d 0.1.3 archive
0.1.1 Mar 6, 2013 Go to the documentation of box2d 0.1.1 Download box2d 0.1.1 archive
0.1.0 Mar 6, 2013 Go to the documentation of box2d 0.1.0 Download box2d 0.1.0 archive

All 18 versions...


We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
71 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
99 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:box2d/box2d.dart.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 42 hints.

    Strong-mode analysis of lib/src/collision/aabb.dart gave the following hint:

    line: 216 col: 26
    'MAX_FINITE' is deprecated and shouldn't be used.

    Strong-mode analysis of lib/src/collision/broadphase/dynamic_tree.dart gave the following hint:

    line: 401 col: 31
    'MAX_FINITE' is deprecated and shouldn't be used.

    Similar analysis of the following files failed:

    • lib/src/collision/collision.dart (hint)
    • lib/src/collision/shapes/circle_shape.dart (hint)
    • lib/src/collision/shapes/polygon_shape.dart (hint)
    • lib/src/dynamics/island.dart (hint)
    • lib/src/dynamics/joints/distance_joint.dart (hint)
    • lib/src/dynamics/joints/mouse_joint.dart (hint)
    • lib/src/dynamics/joints/weld_joint.dart (hint)
    • lib/src/dynamics/joints/wheel_joint.dart (hint)
    • lib/src/dynamics/profile.dart (hint)
    • lib/src/math_utils.dart (hint)
    • lib/src/particle/particle_system.dart (hint)
    • lib/src/particle/voronoi_diagram.dart (hint)
    • lib/src/settings.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use box2d.dart.


Package Constraint Resolved Available
Direct dependencies
vector_math >=2.0.0 <3.0.0 2.0.7
Dev dependencies
browser >=0.10.0 <0.11.0