analytics_exa_flutter 1.0.7+1 copy "analytics_exa_flutter: ^1.0.7+1" to clipboard
analytics_exa_flutter: ^1.0.7+1 copied to clipboard

unlistedoutdated

Package de analytics.

example/lib/main.dart

import 'package:analytics_exa_flutter/old/exa_analytics.dart';
import 'package:example/page_dois.dart';
import 'package:example/page_um.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:inngage_plugin/inapp/inapp_widget.dart';
import 'package:inngage_plugin/models/inngage_web_view_properties_model.dart';
import 'configure_firebase_messaging.dart';

GlobalKey<NavigatorState> navigatorKey = GlobalKey();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp();

  final inngageWebViewProperties = InngageWebViewProperties(
    appBarColor: Colors.pink,
    appBarText: Text(
      'AppTitle',
    ),
    backgroundColor: Colors.white,
    loaderColor: Colors.pink,
    debuggingEnabled: true,
    withJavascript: true,
    withLocalStorage: true,
    withZoom: true,
  );

  String token = await FirebaseMessaging.instance.getToken() ?? '';
  await ExaAnalytics().initInngage(
    appTokenInngage: '598296a47378a4f2304c6ce6b7e7d32c',
    navigatorKey: navigatorKey,
    firebaseToken: token,
    inngageIdentifier: 'danrley.silva@exa.com.br',
    // inngageWebViewProperties: inngageWebViewProperties,
    firebaseListenCallback: (data) => print(data),
  );

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);
  final fb = ConfigureFirebasseMessaging();
  // FirebaseAnalyticsObserver observer =
  // FirebaseAnalyticsObserver(analytics: FirebaseAnalytics.instance);
  @override
  Widget build(BuildContext context) {
    fb.init();

    final logger = ExaAnalytics();
    logger.setCurrentScreen(
        screenName: "Main", screenClassOverride: "Sobrescrevendo Main");

    return GetMaterialApp(
      navigatorKey: navigatorKey,
      // navigatorObservers: <NavigatorObserver>[observer],
      getPages: [
        GetPage(
            name: '/pageum',
            page: () {
              return const PageUm();
            }),
        GetPage(
            name: '/pagedois',
            page: () {
              return const PageDois();
            })
      ],
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: InngageInAppWidget(
          child: Scaffold(
        appBar: AppBar(
          title: const Text("Main"),
        ),
        body: Center(
          child: ListView(
            children: [
              OutlinedButton(
                onPressed: () {
                  logger.setLogEvent(
                      params: {"id": 1, "name": "teste1"},
                      eventName: "botao_1");
                  Get.toNamed("/pageum");
                },
                child: const Text("page um"),
              ),
              OutlinedButton(
                onPressed: () {
                  logger.setLogEvent(
                      params: {"id": 2, "name": "teste2"},
                      eventName: "botao_2");
                  Get.toNamed("/pagedois");
                },
                child: const Text("page dois"),
              ),
              buttonMethod(
                  text: 'Alarm On',
                  text2: 'Alarm Off',
                  onPressed1: () async {},
                  onPressed2: () async {},
                  boolean: true),
            ],
          ),
        ),
      )),
    );
  }

  Widget buttonMethod(
      {required String text,
      String? text2,
      Function()? onPressed1,
      Function()? onPressed2,
      bool boolean = false}) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 8.0),
      child: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            if (onPressed1 != null)
              ElevatedButton(
                onPressed: onPressed1,
                child: Text('$text'),
              ),
            if (onPressed2 != null && text2 != null)
              ElevatedButton(
                onPressed: onPressed2,
                child: Text('$text2'),
              ),
          ],
        ),
      ),
    );
  }

  Widget button({
    required String text,
    Function()? onPressedReq,
    Function()? onPressedCheck,
  }) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 8.0),
      child: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            if (onPressedCheck != null)
              ElevatedButton(
                onPressed: onPressedCheck,
                child: Text('$text check'),
              ),
            if (onPressedReq != null)
              ElevatedButton(
                onPressed: onPressedReq,
                child: Text('$text request'),
              ),
          ],
        ),
      ),
    );
  }

  void showSnackBar({
    required BuildContext context,
    required String message,
    Duration? duration,
  }) {
    print(message);
    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,
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
215
downloads

Publisher

unverified uploader

Weekly Downloads

Package de analytics.

Homepage

License

unknown (license)

Dependencies

appsflyer_sdk, firebase_analytics, flutter, get_it, inngage_plugin

More

Packages that depend on analytics_exa_flutter