Box2D is a 2D physics engine, nothing more nothing less. It is light and efficient and while originally written in C++, it has been ported over to quite a lot of languages. And because of that it has been battle-tested on many platforms.

One of the languages it has been ported over to is Dart. Originally by Dominic Hamon and afterwards the project moved to a Google repo. Eventually the team behind Flame forked the repo and republished the engine under box2d_flame. This is package despite the name can be used separately from Flame itself, in case you don’t want to use Flame.

What is Flame?

Flame is a 2D game engine written in Dart on top of the Flutter toolkit.

The Flame ecosystem is modular by design and provides you with a set of, as they put it, out-of-the-way solutions for making your own game in Flutter. And on top of that they also provide integrations with third party tools and applications, one of which is Box2D.

What now?

If you have done a short google on either Flame or Box2D you might have figured out that there is already quite a lot of information on both subjects. For instance the Box2D documentation has enough material for you to get starting with the library, but it is all written for C++. The dart implementation follows the same kind of API as Java or C++ versions but it is based on the “Dart way”, meaning instead of getter/setter methods you will find property getters and setters or the naming of the methods are slightly different because of the way the code is structured.

So in this series of articles I will try and explain the key components in the dart version of Box2D. Each article will have his own example and in some cases it will continues where a previous article stopped. That way you play with the code yourself.

Next up: Setup

See Dart Box2D Fundamentals series for all the articles.

Author: The explanations and code examples are based on, I highly suggests to read those articles as well.