olexale / arkit_flutter_plugin

ARKit Flutter Plugin
MIT License
796 stars 225 forks source link

fix type in ARKitPlugin.checkConfiguration #154

Closed ssp closed 3 years ago

ssp commented 3 years ago

The cast fails because _channel.invokeMethod returns a Future<T?>, so don’t cast and pass the ? on to the caller.

olexale commented 3 years ago

Hi @ssp,

Thank you for your contribution! We need to add a note to our users what does that means when the value is null, but it should never be null. May I propose the following changes instead:

  static Future<bool> checkConfiguration(ARKitConfiguration configuration) {
    return _channel.invokeMethod<bool>('checkConfiguration', {
      'configuration': configuration.index,
    }).then((value) => value!);
  }

What do you think?

Kind regards, Oleksandr

olexale commented 3 years ago

Sorry, plan to fix all cast errors today, so I'll merge it with the proposed change. Feel free to open a new PR if you think that this proposition is wrong. Huge thanks for this PR!