Skip to content

Commit

Permalink
fix: type 'Null' is not a subtype of type 'String' in getCurrentUser (#…
Browse files Browse the repository at this point in the history
…46)

It was reported that the mParticle SDK has a null pointer bug when trying to retrieve the mpid on some Android devices.  This commit adds a null check for the mpid before attempting to return a User.
  • Loading branch information
Lukitaduarte authored Jul 10, 2024
1 parent 06df0b9 commit c8073d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/mparticle_flutter_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ class MparticleFlutterSdk {
}

Future<User?> getCurrentUser() async {
String mpid = await _channel.invokeMethod('getMPID');
if (mpid == "") {
return null;
String? mpid = await _channel.invokeMethod('getMPID');
if (mpid != null && mpid.isNotEmpty) {
return new User(mpid);
}
return new User(mpid);
return null;
}

Future<Map> getAttributions() async {
Expand Down

0 comments on commit c8073d1

Please sign in to comment.