Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does flutter support both ARCore and ARKit plugin in a single app?

I'm trying Flutter AR app for cross platform, is it possible to use both plugin in a single app. With single code base(ARKit code) will it work for android platform and vise versa or do we need to work independently for individual platform ?

dependencies:
   arcore_flutter_plugin: ^0.0.2+1
   arkit_plugin: ^0.3.0
like image 855
Mallikarjun Hampannavar Avatar asked Oct 24 '19 03:10

Mallikarjun Hampannavar


People also ask

Does Flutter support ARCore?

Plugin Architecture Flutter Plugin for creating (collaborative) Augmented Reality experiences - Supports ARKit for iOS and ARCore for Android devices.

Which is better ARCore or ARKit?

ARKit tends to perform better than ARCore in terms of image tracking and recognition. If you intend to create AR apps that track user gestures to manipulate on-screen images, ARKit will usually be the more efficient option. It translates movements into data faster than Google's alternative.

Can we use AR in Flutter?

In this tutorial, you'll learn about how to build an augmented reality app in Flutter with a plugin that supports both Android and iOS devices. An AR app adds data or visuals to your experience on your camera. Popular examples include Instagram filters, Snapchat filters, various map apps, and more.


2 Answers

Yes, I have managed to combine both plugins in one flutter app so that ARCore runs on Android devices and ARKit on iOS.

To get started, just follow the tutorials to create an arkit app and an arcore app. Then create a new flutter project with both plugins. For the first version, I put the arkit_plugin code in a class I called ArCoreState (extending State for the app) and the arcore_flutter_plugin code in another class, ArKitState.

The main.dart was then simply

void main() => runApp(MaterialApp(home: MultiPlatformApp()));

class MultiPlatformApp extends StatefulWidget {
  @override State<StatefulWidget> createState() => 
     Platform.isAndroid ? ArCoreState() : ArKitState();
}

When you have that running, you have a cross platform AR app, even if it has only one single line of shared code!

like image 98
Rolf Staflin Avatar answered Nov 15 '22 09:11

Rolf Staflin


I know this has been asked a while ago now, but the problem is still unchanged.

To everyone ending up here because they are trying to develop a cross-platform AR app with Flutter: Check out this GitHub Issue Thread.

Among others, I'm currently working on a Flutter plugin that supports both ARCore and ARKit with a common interface, so people can write proper cross-platform apps with shared code and functionality. I'll be posting updates into the GitHub discussion linked above!

EDIT

The plugin is now available at: https://pub.dev/packages/ar_flutter_plugin

like image 33
Lars Avatar answered Nov 15 '22 10:11

Lars