jorgefspereira / plaid_flutter

Plaid Link for Flutter. Integrates the native iOS, Android and Web SDKs.
https://pub.dev/packages/plaid_flutter
MIT License
67 stars 44 forks source link

Unhandled Exception: type 'Null' is not a subtype of type 'String' #94

Closed yisusparkr closed 1 year ago

yisusparkr commented 1 year ago

Plugin version: 3.0.1

OS: iOS & Android

Steps to reproduce: Complete a identity verification flow successfully.

Hi @jorgefspereira, hope you are doing great! I'm having the following issue once the identity verification flow is completed successfully:

E/flutter (12422): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter (12422): #0      new LinkEventMetadata.fromJson
metadata.dart:264
E/flutter (12422): #1      new LinkEvent.fromJson
events.dart:80
E/flutter (12422): #2      PlaidMethodChannel.onObject.<anonymous closure>
plaid_method_channel.dart:28
E/flutter (12422): #3      _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
E/flutter (12422): #4      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
E/flutter (12422): #5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
E/flutter (12422): #6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (12422): #7      _DelayedData.perform (dart:async/stream_impl.dart:515:14)
E/flutter (12422): #8      _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
E/flutter (12422): #9      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
E/flutter (12422): #10     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (12422): #11     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

This issue is happening consistently including if the verification is already completed and the user close and re-open the verification link.

It seems that the error is coming from the following LinkEventMetadata factory method

  factory LinkEventMetadata.fromJson(dynamic json) {
    return LinkEventMetadata(
      viewName: json["viewName"],
      exitStatus: json["exitStatus"],
      mfaType: json["mfaType"],
      requestId: json["requestId"],
      timestamp: json["timestamp"],
      linkSessionId: json["linkSessionId"],
      institutionName: json["institutionName"],
      institutionId: json["institutionId"],
      institutionSearchQuery: json["institutionSearchQuery"],
      errorType: json["errorType"],
      errorCode: json["errorCode"],
      errorMesssage: json["errorMessage"],
    );
  }

Being specific, it comes from the field json["exitStatus"], where we are expecting a String and not a String?.

BTW, I've implemented this plugin in two different projects and in both I'm facing this issue in version 3.0.1 but in the version 2.2.2 this is not happening.

jorgefspereira commented 1 year ago

Still needs some testing but I'll release a new version with the issue fixed in the next couple of days.