An analytics integration joins application initialization, navigation observation, and explicit event calls. This earlier FlutterFire note declared:
dependencies:
firebase_core: ^0.5.0
firebase_analytics: ^6.0.1
Native and application setup
1. Update android/build.gradle
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
2. Update android/app/build.gradle.
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.5.0'
}
apply plugin: 'com.google.gms.google-services'
class MyApp extends StatelessWidget {
static FirebaseAnalytics analytics = FirebaseAnalytics();
static FirebaseAnalyticsObserver observer =
FirebaseAnalyticsObserver(analytics: analytics);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Firebase Analytics Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
navigatorObservers: <NavigatorObserver>[observer],
home: MyHomePage(
title: 'Firebase Analytics Demo',
analytics: analytics,
observer: observer,
),
);
}
}
The application reused its analytics object and supplied an observer for navigation. The constructor and plugin versions are historical, not a current SDK recipe.
The event example
await analytics.logEvent(
name: 'test_event',
parameters: <String, dynamic>{
'string': 'string',
'int': 42,
'long': 12345678910,
'double': 42.0,
'bool': true,
},
);
Calling an event method and seeing a processed dashboard entry are separate observations. The old waiting-time suggestion is not a delivery guarantee. Collection preferences, event contents, and the intended measurement need review in the actual application.
No event was sent and no analytics dashboard accessed for this revision.