Did you know?
If your app uses GoRouter with shell routes, tracking screen views reliably requires some workarounds.
Here's how I do it (using Riverpod):
- Declare GoRouter inside a Riverpod provider
- Create a stateful GoRouter listener to track screen views
- Return it inside
MaterialApp.builder
Here's a PR showing how I implemented this in my Time Tracker app:
And here's the original GoRouter issue showing that NavigatorObserver
doesn't work with shell routes:
Happy coding!