Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

arkit_flutter_plugin

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 or newer is required.

usage

depend on it

follow the installation instructions from dart packages site.

update info.plist

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>

update podfile

at the top level of the ios folder uncomment the second line in the podfile and change the ios minimum version from 9.0 to the appropriate one.
the minimum supported ios version is 11.0, though if you need image anchors use 11.3, for image tracking configuration or face tracking set 12.0, and for body tracking minimum version must be 13.0.

from:

# platform :ios, '9.0'

to:

platform :ios, '11.0'

note: if when running for the first time you get a cocoapods error, delete the podfile.lock file in the ios folder. open the ios folder in the terminal and run:

pod install

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:

demo--2-

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. some samples rely on this earth image

name description link demo
hello world the simplest scene with different geometries. code twitter
check configuration shows which kinds of ar configuration are supported on the device code
earth sphere with an image texture and rotation animation. code twitter
tap sphere which handles tap event. code twitter
midas turns walls, floor, and earth itself into gold by tap. code twitter
plane detection detects horizontal plane. code twitter
distance tracking detects horizontal plane and track distance on it. code twitter
measure measures distances code twitter
physics a sphere and a plane with dynamic and static physics code twitter
image detection detects earth photo and puts a 3d object near it. code twitter
network image detection detects mars photo and puts a 3d object near it. code
custom light hello world scene with a custom light spot. code
light estimation estimates and applies the light around you. code twitter
custom object place custom object on plane. code twitter
occlusion spheres which are not visible after horizontal and vertical planes. code twitter
manipulation custom objects with pinch and rotation events. code twitter
face tracking face mask sample. code twitter
panorama 360 photo. code twitter
video 360 video. code twitter
custom animation custom object animation. port of https://github.com/eh3rrera/arkitanimation code twitter
widget projection flutter widgets in ar code twitter
real time updates calls a function once per frame code
snapshot make a photo of ar content code

if you prefer video here is a playlist with “ar in flutter” videos:

ux advice

you might want to check the device capabilities before establishing an ar session. review the check support sample for the implementation details.

before you go to appstore

the plugin supports truedepth api. in case you didn’t use it, your app will be rejected by apple. hence you need to remove any truedepth functionality by modifying your podfile file

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      ... # here are some configurations automatically generated by flutter

      config.build_settings['other_swift_flags'] = '-ddisable_truedepth_api'
    end
  end
end

faq

  • is it possible to use this plugin on android?
    no, as arkit is not available on android. you might want to try arcore plugin instead.
  • my app crashes when i open the ar scene several times. why?
    most probably that’s because you didn’t call dispose method on the arkit controller.
  • one of the features i need is merged in the repository, but is not available on pub.dev. how can i use the latest version?
    you may use the latest version by changing the pubspec.yaml dependency to:
dependencies:
  arkit_plugin:
    git: git://github.com/olexale/arkit_flutter_plugin.git

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.