analytics_exa_flutter 1.5.0 copy "analytics_exa_flutter: ^1.5.0" to clipboard
analytics_exa_flutter: ^1.5.0 copied to clipboard

unlistedoutdated

Package de analytics.

example/lib/main.dart

import 'dart:io';

import 'package:analytics_exa_flutter/analytics_exa_flutter.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

GlobalKey<NavigatorState> navigatorKey = GlobalKey();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final ExaAnalytics _exaAnalytics;

  @override
  void initState() {
    super.initState();
    getData();
  }

  String getAppId() {
    if (Platform.isAndroid) {
      return 'br.com.exa.pix.security';
    } else if (Platform.isIOS) {
      return '1629719447';
    } else {
      throw Exception('flyer apps should be used on android or ios');
    }
  }

  Future getData() async {
    final amplitudeProps = AmplitudeProps(
      apiKey: '259b34a6c0b0203b64e9b9e2e31e6273',
    );

    final appFlyerProps = AppFlyerProps(
      afDevKey: 'Vz4UVrKJbeeSq7XbAN6VGT',
      appId: getAppId(),
    );

    _exaAnalytics = ExaAnalytics();

    _exaAnalytics.init(
      inngageProps: null,
      appFlyerProps: appFlyerProps,
      amplitudeProps: amplitudeProps,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      title: 'Analytics Exa Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Analytics Exa Example"),
        ),
        body: Center(
          child: ListView(
            children: [
              _elevatedButtonCustom(
                onPressed: () {
                  _exaAnalytics.setCurrentScreen(screenName: "screenName");
                },
                child: const Text("setCurrentScreen"),
              ),
              _elevatedButtonCustom(
                onPressed: () {
                  _exaAnalytics.setLogEvent(
                    eventName: 'setLogEvent',
                    params: {
                      'param1': 'param1',
                      'param2': 'param2',
                    },
                  );
                },
                child: const Text("setLogEvent"),
              ),
              _elevatedButtonCustom(
                onPressed: () {
                  _exaAnalytics.setLogUserId(
                    id: 'setLogUserId',
                  );
                },
                child: const Text("setLogUserId"),
              ),
              _elevatedButtonCustom(
                onPressed: () {
                  _exaAnalytics.setLogUserProperties(
                    name: 'setLogUserProperties',
                    value: 'userId',
                    customFields: {
                      'param1': 'param1',
                      'param2': 'param2',
                    },
                    listUseOnly: [
                      UseAnalyticsOnly.firebase,
                      UseAnalyticsOnly.inngage,
                    ],
                  );
                },
                child: const Text("setLogUserProperties"),
              ),
            ],
          ),
        ),
      ),
    );
  }

  void showSnackBar({
    required BuildContext context,
    required String message,
    Duration? duration,
  }) {
    ScaffoldMessenger.of(context).clearSnackBars(); //clear any snack bars in queue and show current one
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        backgroundColor: Colors.blue,
        duration: duration ?? const Duration(seconds: 3),
        content: Text(
          message,
          style: const TextStyle(
            fontSize: 16,
            color: Colors.white,
          ),
        ),
      ),
    );
  }
}

Widget _elevatedButtonCustom({
  required Function() onPressed,
  required Widget child,
}) {
  return Padding(
    padding: const EdgeInsets.all(8.0),
    child: ElevatedButton(
      onPressed: onPressed,
      child: child,
    ),
  );
}
0
likes
0
points
215
downloads

Publisher

unverified uploader

Weekly Downloads

Package de analytics.

Homepage

License

unknown (license)

Dependencies

amplitude_flutter, appsflyer_sdk, firebase_analytics, flutter, get_it, inngage_plugin

More

Packages that depend on analytics_exa_flutter