Synerise / synerise-flutter-sdk

Synerise SDK plugin for Flutter
Apache License 2.0
5 stars 0 forks source link

SDK is expecting non-null bool type where method channel can return null #3

Closed tomkadziolka closed 1 year ago

tomkadziolka commented 1 year ago

I am experiencing error log with message:

type 'Null' is not a subtype of type 'bool'<…>

This happens for the invocation of method: Synerise.client.authenticate(...)

Where:

bool isAuthenticated = await methodChannel.invokeMethod('Client/authenticate', authenticateMap);

And under the hood, we can see:

  @optionalTypeArgs
  Future<T?> invokeMethod<T>(String method, [ dynamic arguments ]) {
    return _invokeMethod<T>(method, missingOk: false, arguments: arguments);
  }

And as interface states, the api on the other end returns null.

Probably this error can happen also for other SDK functions that are consuming invokeMethod result

konned commented 1 year ago

Hi. Can you provide more information ( what platform) and steps how to reproduce this error? Have you implemented catchError mechanism?

final bool result = await Synerise.client.authenticate(clientAuthContext, identityProvider, tokenString).catchError((error) { // handle error here });

tomkadziolka commented 1 year ago

Method catchError() is not a solution when all function (auth flow) is executed properly and there were no logic errors.

Your library exposes non-null Future<bool> return type and expects bool isAuthenticated type where result from invokeMethod(...) can anytime be null.

This is syntax problem and dealing with platform channels we should not expect non null result

konned commented 1 year ago

I know it is not a solution I am just asking ;) Are you experiencing this issue on both platforms?

tomkadziolka commented 1 year ago

@konned I didn't want to sound rude :), I have done re-check and it seems I cannot reproduce this error message on both Android and iOS for SDK version 0.7.0.

This could happen on 0.6.3 before library updates.

soczowinski commented 1 year ago

Thank you for your report and cooperation, I'm closing this issue since we also were not able to reproduce this error message on SDK version 0.7.0.