Question

Initialize CustomerInfo error


Badge +3

Hi,

I am adding revenueCat into my app and have copied parts of the purchase product code into a new form. 

I am using flutter 3.3.10 and it is not compiling the example without a lot of exceptions. I think I have addressed most issues, however I am stumped on the customerInfo.

In the example its declaired at the start of the class as:

CustomerInfo _customerInfo;

However flutter will not accept this and requires it to be either initialise or marked as late. If you mark it as late then you get an exception error as soon as you try and run the code long before its set.

How do you initialise _customerInfo?

Is there example code that works with the latest release of flutter?

many thanks


2 replies

Badge +3

Follow-uo - Sorted now, re-organised code and got round the initialisation issues. 

Userlevel 4
Badge +6

Hey Richard, 

 

Glad to hear this was solved. For future reference, we have a document here on getCustomerInfo with a Flutter snippet. 

try {
CustomerInfo customerInfo = await Purchases.getCustomerInfo();
// access latest customerInfo
} on PlatformException catch (e) {
// Error fetching customer info
}

 

Reply