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

Viewed 5950

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
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!

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

Related