🚆 Routing & Firebase Analytics

Configure Flutter screen routing for Firebase Analytics

Firebase Analytics and Routing

Add Firebase Analytics to keep track of the user’s navigation between screens.

file_type_dartlang main.dart
import 'package:flutter/material.dart';
import 'package:firebase_analytics/observer.dart';
import 'package:firebase_analytics/firebase_analytics.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        // Firebase Analytics
        navigatorObservers: [
          FirebaseAnalyticsObserver(analytics: FirebaseAnalytics()),
        ],

        routes: {
          '/': (context) => LoginScreen(),
          '/topics': (context) => TopicsScreen(),
          '/profile': (context) => ProfileScreen(),
          '/about': (context) => AboutScreen(),
        },

        // Theme
        theme: ThemeData(
            // your customizations here
            brightness: Brightness.dark,
          ),
        ),
      );
  }
}

Questions? Let's chat

Open Discord