diff --git a/android/src/main/kotlin/com/mparticle/mparticle_flutter_sdk/MparticleFlutterSdkPlugin.kt b/android/src/main/kotlin/com/mparticle/mparticle_flutter_sdk/MparticleFlutterSdkPlugin.kt index 71fd3fa..4cf7a5e 100644 --- a/android/src/main/kotlin/com/mparticle/mparticle_flutter_sdk/MparticleFlutterSdkPlugin.kt +++ b/android/src/main/kotlin/com/mparticle/mparticle_flutter_sdk/MparticleFlutterSdkPlugin.kt @@ -800,24 +800,23 @@ class MparticleFlutterSdkPlugin: FlutterPlugin, MethodCallHandler { .put("timestamp", timestamp) fun MethodCall.toCCPAConsent(result: Result): CCPAConsent? { - return try { - argument("consented")?.let { - CCPAConsent.builder(it) - .document(argument("document")) - .hardwareId(argument("hardwareId")) - .location(argument("location")) - .timestamp(argument("timestamp")) - .build() + return try { + argument("consented")?.let { consented -> + CCPAConsent.builder(consented) + .document(argument("document")) + .hardwareId(argument("hardwareId")) + .location(argument("location")) + .timestamp(argument("timestamp")) + .build() + } ?: run { + result.error(TAG, "Missing \"consented\" value for arguments: $arguments", null) + null + } + } catch (ex: Exception) { + result.error(TAG, ex.message, null) + null } - ?: run { - result.error(TAG, "Missing \"consented\" value for arguments: $arguments", null) - null - } - } catch (ex: Exception) { - result.error(TAG, ex.message, null) - null } -} fun MethodCall.toGDPRConsent(result: Result): Pair? {