Using Firebase Analytics in Flutter

In short, the problem is that these are not named routes.

The reason this is a problem you can see by looking at the implementation of `FirebaseAnalyticsObserver`:`FirebaseAnalyticsObserver` calls `_sendScreenView` for each navigation and uses the `defaultNameExtractor` to determine the screen name.

If that resolves to `null`, then no event gets logged.

The `defaultNameExtractor` just uses the `name` property of the supplied `RouteSettings`.

And this is the problem; in the navigation examples I gave above there are no `RouteSettings`, so the `screenName` ends up as `null` and nothings gets logged.

SolutionThankfully, the solution is pretty simple.

Either use named routes when navigating, or supply a `RouteSettings` instance with your navigation such as:Extra TipIf you want to see the events in Firebase Console quickly and reliably while debugging, use DebugView.

AndroidTo enable Analytics Debug mode on an Android device, execute the following command line:adb shell setprop debug.

firebase.

analytics.

app <package_name>This behavior persists until you explicitly disable Debug mode by executing the following command line:adb shell setprop debug.

firebase.

analytics.

app .

none.

iOSTo enable Analytics Debug mode on your development device, specify the following command line argument in Xcode :-FIRDebugEnabledThis behavior persists until you explicitly disable Debug mode by specifying the following command line argument:-FIRDebugDisabledNote: Before using DebugView, you should ensure that your device time is accurate.

A skewed device clock will result in delayed or missing events in your Analytics reports.

For more information about using Firebase, check out the docs on flutter.

dev.

.

. More details

Leave a Reply