1

I'm using RevenueCat on Flutter, where do I call:

Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {});

so that I can listen for updates to purchase status across my entire app? Thanks.

John
  • 2,551
  • 3
  • 17
  • 29

1 Answers1

2

You can Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {}); to the initState of your app widget.

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(),
    );
  }
}
JideGuru
  • 7,102
  • 6
  • 26
  • 48