Start a Project

How to Build an AR App in Flutter

In this blog, we will learn how to build an AR app in Flutter.

Introduction

An AR App in Flutter places digital objects inside the live camera view. It helps users interact with 3D content in their surroundings.

This project uses AR Flutter Plugin Plus to detect horizontal planes, anchor a remote GLB model, and support rotation and pinch-to-zoom gestures.

The tutorial covers Flutter dependencies and the required Android and iOS settings. It then explains the complete placement and transformation flow.

Before starting, explore more Flutter tutorials on Mobikul.

Requirements for an AR App in Flutter

Therefore, use a physical Android or iOS device with augmented-reality support. The app needs camera access, internet access, and enough light to detect surfaces.

For Android testing, confirm your phone appears in Google’s ARCore supported-device list. An emulator may not reproduce the complete camera experience.

Add Flutter AR Dependencies

First, the project uses AR Flutter Plugin Plus for the AR session. In addition, vector_math creates scale and rotation vectors.

File path: pubspec.yaml

Run flutter pub get after saving the file. You can also review the AR Flutter Plugin Plus package for platform notes.

Configure AR on Android

First, Android needs camera and internet permissions. In addition, the AR camera feature and ARCore metadata mark augmented reality as a required capability.

File path: android/app/src/main/AndroidManifest.xml

Next, set the minimum Android SDK to 24. This setting matches the platform requirement used by the verified project.

File path: android/app/build.gradle.kts

Configure AR on iOS

Similarly, iOS needs a clear camera usage message. Moreover, the ARKit capability prevents installation on unsupported devices.

File path: ios/Runner/Info.plist

Therefore, the project targets iOS 15 and enables the camera permission definition for its pods. Add these values to the existing Podfile configuration.

File path: ios/Podfile

Create the AR App in Flutter

First, the main screen starts a horizontal-plane AR session. Then, a tap anchors and loads a remote GLB model on a detected plane.

Next, a one-finger drag rotates the model. Meanwhile, a two-finger pinch changes its size within a safe range.

File path: lib/main.dart

How AR Placement Works

First, the camera scans for horizontal planes. Then, a tap returns hit-test results from the detected environment.

The code accepts a plane result and creates an anchor at its world transform. It attaches the GLB node only after the anchor succeeds.

Moreover, the app blocks duplicate placement while a model is loading. Clear messages explain scanning, loading, success, and failure states.

Run the AR App in Flutter

Finally, connect a supported physical device and run flutter run. Then, allow camera access when the operating system displays its permission prompt.

Move the phone slowly until a surface appears. Next, tap the surface, drag with one finger, and pinch with two fingers.

However, if placement fails, check lighting, network access, and device support. Also confirm that the remote GLB URL is reachable.

Here is the Output of the Project

Conclusion

In conclusion, you built an AR App in Flutter with plane detection, model placement, rotation, and scaling. The same structure can support other GLB models.

For more mobile-development guidance, browse the Mobikul blog.

Thanks for reading this blog.
Please check my other blogs here.
Read more Flutter blogs

Exit mobile version