CariusLars / ar_flutter_plugin

Flutter Plugin for AR (Augmented Reality) - Supports ARKit on iOS and ARCore on Android devices
MIT License
333 stars 254 forks source link

Android ArViewCreated Bug! #185

Closed Dabbit-Chan closed 1 year ago

Dabbit-Chan commented 1 year ago

What I do is Just make ARView in a scaffold, and then it failed

[ +190 ms] E/MethodChannel#flutter/platform_views( 5956): Failed to handle method call
[        ] E/MethodChannel#flutter/platform_views( 5956): java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
[        ] E/MethodChannel#flutter/platform_views( 5956):   at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:118)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at android.os.Handler.handleCallback(Handler.java:883)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at android.os.Handler.dispatchMessage(Handler.java:100)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at android.os.Looper.loop(Looper.java:214)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at android.app.ActivityThread.main(ActivityThread.java:7697)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at java.lang.reflect.Method.invoke(Native Method)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
[        ] E/MethodChannel#flutter/platform_views( 5956):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
[  +26 ms] E/flutter ( 5956): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
[        ] E/flutter ( 5956):   at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:118)
[        ] E/flutter ( 5956):   at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:60)
[        ] E/flutter ( 5956):   at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
[        ] E/flutter ( 5956):   at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
[        ] E/flutter ( 5956):   at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
[        ] E/flutter ( 5956):   at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
[        ] E/flutter ( 5956):   at android.os.Handler.handleCallback(Handler.java:883)
[        ] E/flutter ( 5956):   at android.os.Handler.dispatchMessage(Handler.java:100)
[        ] E/flutter ( 5956):   at android.os.Looper.loop(Looper.java:214)
[        ] E/flutter ( 5956):   at android.app.ActivityThread.main(ActivityThread.java:7697)
[        ] E/flutter ( 5956):   at java.lang.reflect.Method.invoke(Native Method)
[        ] E/flutter ( 5956):   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
[        ] E/flutter ( 5956):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
[        ] E/flutter ( 5956): )
[        ] E/flutter ( 5956): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
[        ] E/flutter ( 5956): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:296:18)
[        ] E/flutter ( 5956): <asynchronous suspension>
[        ] E/flutter ( 5956): #2      PlatformViewsService.initUiKitView (package:flutter/src/services/platform_views.dart:237:5)
[        ] E/flutter ( 5956): <asynchronous suspension>
[        ] E/flutter ( 5956): #3      _UiKitViewState._createNewUiKitView (package:flutter/src/widgets/platform_view.dart:642:44)
[        ] E/flutter ( 5956): <asynchronous suspension>
[        ] E/flutter ( 5956): 
Dabbit-Chan commented 1 year ago

I find where is that bug. Please don't use Theme.of(context).platformto get the platfrom, just use Platform.isAndroid and Platform.isIOS! @CariusLars