ambilytics 1.0.7 copy "ambilytics: ^1.0.7" to clipboard
ambilytics: ^1.0.7 copied to clipboard

Google Analytics for all Flutter platfroms (Android, iOS, macOS, Web, Windows and Linux)

example/lib/main.dart

import 'package:ambilytics/ambilytics.dart' as ambilytics;
import 'package:ambilytics_example/color_screen.dart';
import 'package:ambilytics_example/preferences.dart';
import 'package:flutter/material.dart';

import 'firebase_options.dart';
import 'home_screen.dart';

void main() async {
  // Inits either Firebase Analytics (macOS, iOS, Android, Web) or GA4 Measurement Protocol, sends out app_launch event with current platform as param
  var disable = !(await getShareAnalyticsPreference());

  await ambilytics.initAnalytics(
      measurementId: 'G-6R363DDKTZ',
      apiSecret: 'uzUv6h_iRS6hEt_sIVtTTA',
      disableAnalytics: disable,
      firebaseOptions: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      navigatorObservers: ambilytics.isAmbilyticsInitialized
          ? [
              ambilytics.AmbilyticsObserver(
                  // Track dialog routes pushed via showDialog()
                  routeFilter: ambilytics.anyRouteFilter,
                  alwaySendScreenViewCust: true)
            ]
          : [],
      routes: {
        '/': (context) => HomeScreen(
              title: 'Home',
              analyticsError: ambilytics.initError,
            ),
        '/color/red': (context) => const ColorScreen(),
        '/color/yellow': (context) => const ColorScreen()
      },
    );
  }
}
26
likes
160
points
1.69k
downloads

Publisher

verified publishersaplin.blogspot.com

Weekly Downloads

Google Analytics for all Flutter platfroms (Android, iOS, macOS, Web, Windows and Linux)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

firebase_analytics, firebase_core, flutter, http, shared_preferences, uuid

More

Packages that depend on ambilytics