Search code examples
flutterarkitarcore

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

Solution

  • 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 arcore_flutter_plugin code in a class I called ArCoreState (extending State for the app) and the arkit_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!