我正在使用下面的简单代码
bool available = await InAppPurchaseConnection.instance.isAvailable();
但是它正在返回错误
E/flutter (14525): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: 'package:in_app_purchase/src/billing_client_wrappers/billing_client_wrapper.dart': Failed assertion: line 101 pos 12: '_enablePendingPurchases': enablePendingPurchases() must be called before calling startConnection
我想知道是否有人知道这个错误的原因,如果是的话我应该怎么做,很高兴有任何建议 - 谢谢。
最佳答案
文档在这方面非常薄,实际上应该更清楚。您需要在 main() 中包含以下行才能使其工作。
void main() {
///Include this in main() so purchases are enabled
InAppPurchaseConnection.enablePendingPurchases();
runApp(MyApp());
}
关于 flutter in_app_purchase '_enablePendingPurchases' : enablePendingPurchases() must be called before calling startConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60046903/