flutter_r2u 0.0.2 copy "flutter_r2u: ^0.0.2" to clipboard
flutter_r2u: ^0.0.2 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

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

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

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  final String customerId = '5e8e7580404328000882f4ae';
  final String sku = 'RE000001';

  bool init = false;
  bool isActive = false;
  bool supportsAR = false;

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

  Future<void> initPlatformState() async {
    try {
      await R2U.init(customerId: customerId);
      init = true;
      supportsAR = await R2U.deviceSupportsAR();
      print("supportsAR " + supportsAR.toString());

      isActive = await R2U.isActive(sku);
      print("isActive " + isActive.toString());
    } on PlatformException {
      print('Failed to init R2U Flutter SDK');
    }

    if (!mounted) return;
  }

  void onPressed() {
    R2U.openAR(sku: sku);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text('R2U Flutter SDK'),
          ),
          body: Center(
              child: Column(children: <Widget>[
            Container(
              margin: EdgeInsets.all(25),
              child: ElevatedButton(
                child: Text(
                  'View in your space',
                  style: TextStyle(fontSize: 20.0),
                ),
                onPressed: init && supportsAR && isActive ? onPressed : null,
              ),
            ),
          ]))),
    );
  }
}
1
likes
90
pub points
0%
popularity

Publisher

verified publisherr2u.io

A new flutter plugin project.

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, http

More

Packages that depend on flutter_r2u