我在Flutter上使用RevenueCat,我该在哪里调用:
Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {});这样我就可以在我的整个应用程序中监听购买状态的更新?谢谢。
发布于 2020-08-28 05:28:27
您可以通过Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {});连接到您的应用程序小部件的initState。
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {
// do what you want with the purchase info
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: Constants.appName,
theme: ThemeConfig.lightTheme,
home: Splash(),
);
}
}https://stackoverflow.com/questions/63624288
复制相似问题