ricoh_theta_plugin

A flutter plugin for Ricoh Theta camera.

Features

  • Taking a picture
  • Timer (1 to 10 seconds)
  • Capture options (HDR, DR Compensation, Noise Reduction)
  • Adjust the brightness

Supported Languages

  • English
  • Japanese
  • Korean

Installation

Add ricoh_theta_plugin as a dependency.

dependencies:
  flutter:
    sdk: flutter
  ricoh_theta_plugin: ^0.0.5

iOS

Allow access wifi information Add this line in Podfile

config.build_settings['SWIFT_VERSION'] = '4.2'

Android

Change the minimum Android sdk version to 16 or higher in your android/app/build.gradle file.

minSdkVersion 16

Example

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:ricoh_theta_plugin/ricoh_theta_plugin.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _imageUri;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion = await RicohThetaPlugin.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  Future startCamera() async {
    try {
      String imageUri = await RicohThetaPlugin.startCamera();
      setState(() => this._imageUri = imageUri);
    } on PlatformException catch (e) {
      print('error: $e');
    } on FormatException{
      print('null (User returned using the "back"-button before scanning anything. Result)');
    } catch (e) {
      print('error: $e');
    }
  }

  Widget _showUri(){
    if(_imageUri != null && _imageUri.isNotEmpty){
      File file = new File(_imageUri.replaceAll("file:", ""));
      return new Container(
          width: 300.0,
          child:new Column(
            children:[
              Text(
                '$_imageUri\n',
                style: TextStyle(fontSize: 10),
              ),
              new Image.file(
                file,
                width: 600.0,
                height: 240.0,
                fit: BoxFit.cover,
              ),
            ]
          )


      );
    }
    return Container();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Ricoh Theta Plugin Sample App'),
        ),
        body: Center(
            child:
            new Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children:[
                  Text('Running on: $_platformVersion\n'),
                  _showUri(),
                  RaisedButton(
                    splashColor: Colors.pinkAccent,
                    color: Colors.black,
                    child: new Text(
                      "Start Camera",
                      style: new TextStyle(fontSize: 20.0, color: Colors.white),
                    ),
                    onPressed: () {
                      startCamera();
                    },
                  ),
                ])
        ),
      ),
    );
  }
}

Libraries

ricoh_theta_plugin

Dart

VM

dart:ffi
Foreign Function Interface for interoperability with the C programming language. [...]

Web

dart:html
HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
dart:js
Low-level support for interoperating with JavaScript. [...]
dart:js_util
Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.