Menu

Flutter Firebase Analytics screen tracking with go_router
📰

Flutter Firebase Analytics screen tracking with go_router

DEV Community: dart·Yevhen Beshkarov·3 days ago
#IJThX33s
#devtodart#devto#dev#home#screen
Reading 0:00
15s threshold

The usual advice for Flutter Firebase Analytics screen tracking is to give FirebaseAnalyticsObserver to GoRouter . In an app with tabs, it misses screens. Going back to a tab the user has already opened logs nothing, and neither does closing a page that was opened over the tabs. A go() to a nested route logs every parent page as well, under names like b and c . I checked this on go_router 18.1.1 and firebase_analytics 13.0.0, with Flutter 3.44.2 and 3.47.4. A listener on the router delegate logs one screen view for each screen the user sees, in about 30 lines.

What FirebaseAnalyticsObserver logs with go_router tabs

The usual setup:

final router = GoRouter ( observers: [ FirebaseAnalyticsObserver ( analytics: FirebaseAnalytics . instance )], routes: [...], );

Enter fullscreen mode

Exit fullscreen mode

My test app has two tabs in a StatefulShellRoute : /home , which has a child route details , and /settings .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.