'How to count page view in flutter when the user visits the page?

I'm wondering about How to count page view in flutter on each time the user visit the page?

should I use something like Shared_preferences to store the value and updating it in the initState()?

I've seen similar topics here but none get me a clear idea about how to achieve that.



Solution 1:[1]

You can achieve that using google analytics or firebase analytics. You can follow this https://firebase.flutter.dev/docs/analytics/overview/ and add this in your initState

await FirebaseAnalytics.instance
  .setCurrentScreen(
    screenName: 'Products'
  );

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fahmida