flutter_inapp_purchase
flutter_inapp_purchase copied to clipboard
Future<List<PurchasedItem>?>' is not a subtype of type FutureOr<List<PurchasedItem>>
Version of flutter_inapp_purchase
5.2.0
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
returns true or false
Actual behavior
throws error "Future<List<PurchasedItem>?>' is not a subtype of type FutureOr<List<PurchasedItem>>"
Tested environment (Emulator? Real Device?)
real device
Steps to reproduce the behavior
call FlutterInappPurchase.instance.checkSubscribed(...)
Code with error
File flutter_inapp_purchase.dart:
var purchases = await (getAvailablePurchases() as FutureOr<List<PurchasedItem>>); // this line throws the error.
var history = await (getPurchaseHistory() as FutureOr<List<PurchasedItem>>); // and this one too
The fix is very simple. Just replace the code lines mentioned in the description with:
List<PurchasedItem>? historyNullable = await getPurchaseHistory();
var history = historyNullable ?? [];
and
List<PurchasedItem>? purchasesNullable = await getAvailablePurchases();
var purchases = purchasesNullable ?? [];
Thank you for fast update!!!
Any update on this?
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.