Git Product home page Git Product logo

flutter_ar's Introduction

Flutter Ar Demo App

alt

With use of below code you can create AR demo app at your end. You just need to follow below steps

Installation & setup

  • Add below plugins in your project.
dependencies:   arcore_flutter_plugin: ^0.0.2+2
  • Save the file and run the below command.
$  flutter pub get
  • You can download the plugin and import the dart file in your project.
import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';
  • Enable your AR support in your project. Open android menifiest file and add below code
//add this permissions 
<uses-sdk android:minSdkVersion="24" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.ar" />

// add below metadata
<meta-data
android:name="com.google.ar.core"
android:value="required" />
  • Add below depedancies in the build.gradle file.
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.8.0'
implementation 'com.google.ar.sceneform:core:1.8.0'
implementation 'com.google.ar:core:1.8.0'
  • AR plugin requires android x support. Please make sure the app has that support and add below code in gradle.properties.
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
  • Create HomePage Stateful Class and return ArCoreView in Scafold body like below,
class HomePageState extends State<HomePage> {

  ArCoreController arCoreController;

  @override
  void dispose() {
    // TODO: implement dispose
    arCoreController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Ar Demo App"),
        ),
        // add your AR Core View Widget here
        body: ArCoreView(
          onArCoreViewCreated: _onArCoreViewCreated,
        ));
  }
  • The important widget from the plugin is ArCoreView() The Constructor takes 4 named arguments
onArCoreViewCreated,enableTapRecognizer,enableUpdateListener,key
  • Import Following Packages :
import 'package:arcore_flutter_plugin/arcore_flutter_plugin.dart';
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math_64.dart' as vector;
  • do not forget to dispose in dispose() Override method.
  @override
  void dispose() {
    // TODO: implement dispose
    arCoreController.dispose();
    super.dispose();
  }
  • create Sphere to AecoreNode
  void _addSphere(ArCoreController controller) {
    // add colors
    final material = ArCoreMaterial(color: Color.fromARGB(120, 66, 134, 244));
    // create sphere view
    final sphere = ArCoreSphere(
      materials: [material],
      radius: 0.1,
    );
    // add sphere view in the AR code node
    final node = ArCoreNode(
      shape: sphere,
      position: vector.Vector3(0, 0, -1.5),
    );
    controller.addArCoreNode(node);
  }

flutter_ar's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.