olexale / arkit_flutter_plugin

ARKit Flutter Plugin
MIT License
797 stars 225 forks source link

Platform tags on pub.dev lies #96

Closed ManuLpz4 closed 3 years ago

ManuLpz4 commented 4 years ago

image

By the way, any suggestion for AR on Android and iOS devices? 😁

dariocavada commented 4 years ago

I personally used arkit_plugin and arcore_flutter_plugin together, by creating two different screens and enabling only the one supported by the device.

ARKit and ARCore have different differences, not so much for the basic geometries, both for the positioning of an object within the space, but above all for the support of the format for the objects to be displayed in different formats.

Example:

In yaml file:

  arkit_plugin: ^0.5.1
  arcore_flutter_plugin: ^0.0.5+1

In the code:

import '../screens/arcore_screen.dart';
import '../screens/arkit_screen.dart';

... 

/// Show the right Augmented Reality Screen Type
    Widget _arKitOrArCore() {
      if (Theme.of(context).platform == TargetPlatform.android) {
        // ARCore Android
        return ARCoreScreen();
      } else if (Theme.of(context).platform == TargetPlatform.iOS) {
        // ARKit iOS
        return ARKitScreen();
      } else {
        return Container(
          width: 150.00,
          padding: EdgeInsets.fromLTRB(20, 20, 20, 20),
          color: Colors.blueAccent,
          child: Text(
            'AR Not supported',
            textAlign: TextAlign.center,
            style: TextStyle(fontSize: 24, color: Colors.white),
          ),
        );
      }
    }
ManuLpz4 commented 4 years ago

@dariocavada thank you for answer :)

I think it's a good idea and probably what I'll end up implementing, but currently my app with arcore crashes at startup. did you ever have the same problem? (I know it's a little bit off-topic, sorry, I'm going crazy).

olexale commented 4 years ago

Thanks @dariocavada! I would recommend not to use the platform property of the Theme as it supposed to be used to style UI elements according to platform conventions and it is possible to override its value. The more reliable option would be going with Platform, like that:

import 'dart:io' show Platform;

if (Platform.isAndroid) {
  return ARCoreView();
} else if (Platform.isIOS) {
  return ARKitView();
}
olexale commented 3 years ago

Fixed in 0.6.0