AR with Flutter – The Sword of Damocles

Hi! My name is Oleksandr. The first AR experience in the world was called
the “Sword of Damocles”. It was a head-mounted display system. The device was primitive both
in terms of UI and realism. It only showed wireframes. Why don’t we create something
similar with Flutter? Here I have a default sample project. Let’
start with pubspec modification, I need to add an ARKit plugin. For now, the latest version
is 0.3.0, but you should check for updates. Good, one more thing before we start coding.
The AR plugin uses a native view. On iOS, they are not supported by Flutter by default.
To make everything work we need to modify the Info.plist file as it is described in
plugin’s README. Back to code! Let’s remove everything
except the Material App. Now we need a screen with an AR widget. It is a common practice
for native views to provide some kind of controller to.. well.. control these views! Let’s add a node. Node is like a widget
but in AR. And do not forget to add a node to a scene. The scene is a place you put nodes in. Inside the node, we set a geometry. In our
case, that would be a box with 6 centimeters width, height, and length. I’ll put it in
half of a meter in front of the camera. Let’s fix imports and use the widget we just
built. Good! Let’s see what we’ve got. To make our simulation even closer to the
original “Sword of Damocles”, let’s modify the box material. Cool! Now we have the most exciting AR experience
from sixtieth!

1 thought on “AR with Flutter – The Sword of Damocles

Leave a Reply

Your email address will not be published. Required fields are marked *