When user clicks on the purchase button, I want to change _isLoading
variable to true
. Once purchase dialog will appear (on Android or iOS), then set _isLoading
back to false
.
For simplification, the flow I want:
- User clicks on the purchase button (
_isLoading
istrue
) - Purchase dialog appears
_isLoading
isfalse
I tried to do like this:
setState(() => _isLoading = true);
await _iap.buyConsumable(
purchaseParam: PurchaseParam(productDetails: product),
);
setState(() => _isLoading = false);
But on iOS, the _isLoading
immediately goes to false
when user clicks.
2
Answers
you have to listen the purchase lifecycle. IAP using streamer not async await
You can try with catch() and try() (exception handling)