arkit_flutter_plugin

Codemagic build status flutter awesome pub package

Note: ARKit is only supported by mobile devices with A9 or later processors (iPhone 6s/7/SE/8/X, iPad 2017/Pro) on iOS 11 and newer. For some features iOS 12 is required.

Usage

Depend on it

Follow the installation instructions from Dart Packages site.

Update Info.plist

The plugin use native view from ARKit, which is not yet supported by default. To make it work add the following code to Info.plist:

    <key>io.flutter.embedded_views_preview</key>
    <string>YES</string>

ARKit uses the device camera, so do not forget to provide the NSCameraUsageDescription. You may specify it in Info.plist like that:

    <key>NSCameraUsageDescription</key>
    <string>Describe why your app needs AR here.</string>

Write the app

The simplest code example:

import 'package:flutter/material.dart';
import 'package:arkit_plugin/arkit_plugin.dart';
import 'package:vector_math/vector_math_64.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ARKitController arkitController;

  @override
  void dispose() {
    arkitController?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => Scaffold(
      appBar: AppBar(title: const Text('ARKit in Flutter')),
      body: ARKitSceneView(onARKitViewCreated: onARKitViewCreated));

  void onARKitViewCreated(ARKitController arkitController) {
    this.arkitController = arkitController;
    final node = ARKitNode(
        geometry: ARKitSphere(radius: 0.1), position: Vector3(0, 0, -0.5));
    this.arkitController.add(node);
  }
}

Result:

flutter

Examples

I would highly recommend to review the sample from the Example folder. You may find a couple of samples in the Example folder of the plugin.

NameDescriptionLinkDemo
Hello WorldThe simplest scene with different geometries.codetwitter
EarthSphere with an image texture and rotation animation.codetwitter
TapSphere which handles tap event.codetwitter
Plane DetectionDetects horizontal plane.codetwitter
Distance trackingDetects horizontal plane and track distance on it.codetwitter
MeasureMeasures distancescodetwitter
PhysicsA sphere and a plane with dynamic and static physicscodetwitter
Image DetectionDetects an earth image and puts a 3D object near it.codetwitter
Custom LightHello World scene with a custom light spot.code
Light EstimationEstimates and applies the light around you.codetwitter
Custom ObjectPlace custom object on plane.codetwitter
OcclusionSpheres which are not visible after horizontal and vertical planes.codetwitter
ManipulationCustom objects with pinch and rotation events.codetwitter

Contributing

If you find a bug or would like to request a new feature, just open an issue. Your contributions are always welcome!

Libraries

arkit_anchor
arkit_arplane_detection
arkit_box
arkit_capsule
arkit_cone
arkit_cylinder
arkit_geometry
arkit_hit_test_result
arkit_hit_test_result_type
arkit_light
arkit_light_estimate
arkit_light_type
arkit_line
arkit_material
arkit_node
arkit_node_pan_result
arkit_node_pinch_result
arkit_physics_body
arkit_physics_body_type
arkit_physics_shape
arkit_plane
arkit_plugin
arkit_pyramid
arkit_reference_node
arkit_scene_view
arkit_sphere
arkit_text
arkit_torus
arkit_tube
matrix4_utils
random_string
vector_utils