PostHog / posthog-flutter

PostHog Flutter SDK
https://posthog.com/docs/libraries/flutter
MIT License
52 stars 37 forks source link

Fix an issue in the example #56

Closed ueman closed 11 months ago

ueman commented 11 months ago

Calls like Posthog().screen(screenName: 'Example Screen'); should not be done in a widgets build method since the build method is potentially called multiple times. Therefore, this could lead to wrongly recorded analytics with too many screen views. Additionally, the PosthogObserver is already recording that exact screen view.

In this specific example, it might actually be acceptable, though, since it's the root widget. However, an example shouldn't be this nuanced, so it's better to remove it.