Quickstart in Flutter

Set up your Flutter project

Download the Flutter project

Step 1: Download the ARwayKit_SDK_FlutterSamples project from GitHub as a ZIP. You can find the link in the Developer Portal Downloads section.
Download the project as ZIP
It is necessary to download the complete project / entire repository from GitHub.
Step 2: Extract the .zip file and open the project with Android Studio or VS Code.

Configure the Flutter project

Step 1: Open the pubspec.yaml file and add flutter_unity_widget to it under the dependencies section.
flutter_unity_widget: ^3.0.3
Add flutter_unity_widget to pubspec.yaml
We are using the flutter_unity_widget package to integrate our ARWAY Unity SDK with Flutter.
Step 2: After adding the dependencies, you need to fetch them into your Flutter project. You can fetch the dependencies by -
  • From the terminal: Run flutter pub get. OR
  • From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec.yaml.
  • From VS Code: Click Get Packages located on the right side of the action ribbon at the top of pubspec.yaml.
Step 3: Then add an import statement for using the package inside your Dart code.
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
We have created sample Dart files with unity pre-integrated to help you get started quickly with the project. The Dart files are located in the lib folder within the Flutter project.

Configure the Unity Project

Step 1: Add the Unity project located inside the Flutter Samples project, into the Unity Hub. Your project files should look like this.
├── android
├── ios
├── lib
├── linux
├── macos
├── test
├── unity
│ └── <Your Unity Project> // Example: ARwayKit-SDK
├── web
├── windows
├── pubspec.yml
Add project to Unity Hub
Step 2: Open the project with Unity 2019.4.3f1 or above.
Import theFlutterUnityPackage.unitypackage if you don't see a FlutterUnityIntegration folder inside the ARwayKit-SDK project.
Step 3: Open the Package Manager (Window -> Package Manager) and install the following components if not already installed -
  • AR Foundation >= 4.1.1 (2019.4 verified)
  • ARCore XR Plugin >= 4.1.1 (2019.4 verified)
  • ARKit XR Plugin >=4.1.1 (2019.4 verified)
  • Unity XR management >= 3.2.16 (2019.4 verified)
  • TextMesh Pro >= 2.1.1 (2019.4 verified)
Step 4: Go to Player Settings (Edit -> Project Settings -> Player -> Other Settings)
  • Turn off the Auto Graphics API.
  • For iOS:
    • Set Graphics API to Metal.
    • Set Target Minimum Version to 12.0.
  • For Android:
    • Set Graphics API to OpenGLES3.
    • Set Minimum API Level to 24 (Android 7.0).
    • Disable Multithreaded Rendering
Step 5: Add the scenes you wish to build under the Unity build settings. (File -> Build Settings)
Add scenes to Unity Build Settings
DO NOT press the Build or Build And Run buttons are they are not needed here.
Step 6: Now, this is the crucial step. Instead of building the app, go to the Unity menu and then export the Unity project with Flutter/Export Android (for Unity versions 2019.3 and up, which uses the new Unity as a Library export format), or Flutter/Export IOS menu.
Please do not use Flutter/Export <Platform> plugin as it was specially added to work with flutter_unity_cli for larger projects.
Export to Flutter
Android will export unity project to android/unityLibrary.
IOS will export unity project to ios/UnityLibrary.
NOTE: The build unity export script automatically sets things up for you, so you don't have to do anything for android. But if you want to manually set it up, continue, else skip to iOS.

How to use ARWAY SDK Scenes?

For how to use the scenes in the ARWAY Unity SDK or the Azure Spatial Anchors, kindly look at the documentation for those scenes linked below.

Android Platform Only (Manual Steps) (Optional)

Step 1: After exporting the unity game, open Android Studio and then
Step 2: Add the following to your <Your Flutter Project>/android/settings.gradlefile:
include ":unityLibrary"
project(":unityLibrary").projectDir = file("./unityLibrary")
Step 3: Open <Your Flutter Project>/android/app/build.gradlefile and add:
dependencies {
implementation project(':unityLibrary')
Step 4: To build a release package, you need to add signconfig in UnityExport/build.gradle. The code below use the debug signConfig for all buildTypes, which can be changed as you well if you need specify signConfig.
buildTypes {
release {
signingConfig signingConfigs.debug
debug {
signingConfig signingConfigs.debug
signingConfig signingConfigs.debug
innerTest {
matchingFallbacks = ['debug', 'release']
Step 5: If you use minifyEnabled true and need to use UnityMessage in Flutter, please add proguard content below:
-keep class com.xraph.plugins.** {*;}
Step 6: If you want unity in it's own activity as an alternative, just add this to your app AndroidManifest.xml file
<meta-data android:name="com.xraph.plugins.flutterunitywidget.ExtendedUnityActivity" android:value="true" />

iOS Platform Only

Step 1: Open your ios/Runner.xcworkspace (workspace!, not the project) in Xcode and add the exported project in the workspace root (with a right click in the Navigator, not on an item -> Add Files to “Runner” -> add the unityLibrary/Unity-Iphone.xcodeproj file
Step 2: Select the Unity-iPhone/Data folder and change the Target Membership for Data folder to UnityFramework (Optional)
Step 3: Add this to your Runner/Runner/Runner-Bridging-Header.h
#import "UnityUtils.h"
Step 4: Add to Runner/Runner/AppDelegate.swift before the GeneratedPluginRegistrant call:
InitArgs(CommandLine.argc, CommandLine.unsafeArgv)
For example
import UIKit
import Flutter
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
InitArgs(CommandLine.argc, CommandLine.unsafeArgv)
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
Or when using Objective-C your main.m should look like this:
#import "UnityUtils.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
InitArgs(argc, argv);
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Step 5: Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.
Step 6: Add UnityFramework.framework as a Library to the Runner project.

Build And Run:

Step 1: Run the app on Android with the following command. For iOS, build an XCode project to deploy it to an iOS device from the IDE of your choice.
$ flutter run
Step 2: After the app build completes, you’ll see the starter app on your device.
Start Screen
Step 3: Now press the Open ARWAY SDK button to open the Unity Scenes you've added, before exporting the Unity project within the Flutter app itself. It should look something like this depending upon the scene you're building.
Unity Screen


Here are some extra methods and APIs which you can implement to communicate to and from Unity using Flutter.


  • fullscreen (Enable or disable fullscreen mode on Android)
  • disableUnload (Disable unload on iOS when unload is called)


  • pause() (Use this to pause unity player)
  • resume() (Use this to resume unity player)
  • unload() (Use this to unload unity player)
  • quit() (Use this to quit unity player)
  • postMessage(String gameObject, methodName, message) (Allows you invoke commands in Unity from flutter)
  • onUnityMessage(data) (Unity to flutter binding and listener)
  • onUnityUnloaded() (Unity to flutter listener when unity is unloaded)
  • onUnitySceneLoaded(String name, int buildIndex, bool isLoaded, bool isValid,) (Unity to flutter binding and listener when a new scene is loaded)
To see more details check out the package's official documentation linked below.