I have a GetX app and I want to sync the CustomerInfo from Revenuecat with my app (I wasn't sure if this information is necessary so I included it). I basically add a listener to do this:
Purchases.addCustomerInfoUpdateListener((CustomerInfo info) {
print(info.runtimeType);
customerInfo.value = info;
});
The type of
customerInfo is a Rx variable on my GetX controller that looks like this: Rx<CustomerInfo?> customerInfo = null.obs;.
But this doesn't work, because the runtimeType of ìnfo is _$CustomerInfoImpl and not CustomerInfo. I tried casting the value but that doesn't work either. I always get this error:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '_$CustomerInfoImpl' is not a subtype of type 'Null' of 'v'
#0 RxObjectMixin.call (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:62:14)
#1 AccountController.onInit.<anonymous closure> (package:mitt_sjo_liv/controllers/account_controller.dart:311:19)
#2 Purchases.addCustomerInfoUpdateListener (package:purchases_flutter/purchases_flutter.dart:191:33)
#3 AccountController.onInit (package:mitt_sjo_liv/controllers/account_controller.dart:308:15)
For anyone who has the same problem, I found a solution: Instead of using
Rx<CustomerInfo?>, you have to useRxn<CustomerInfo>.