trackier_sdk_flutter 1.6.46 trackier_sdk_flutter: ^1.6.46 copied to clipboard
This is trackier flutter SDK
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:trackier_sdk_flutter/trackierfluttersdk.dart';
import 'package:trackier_sdk_flutter/trackierconfig.dart';
import 'package:trackier_sdk_flutter/trackierevent.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
TrackerSDKConfig trackerSDKConfig = new TrackerSDKConfig(
"abcf2270-d94a-4364-a2ae-34903c6e1d53", "development");
trackerSDKConfig.deferredDeeplinkCallback = (uri){
print('The value of deeplinkUrl is: $uri');
};
Trackierfluttersdk.setPreinstallAttribution("sanuKing", "babu", "don");
Trackierfluttersdk.updatePostbackConversion(0);
Trackierfluttersdk.setUserId("737263"); //Pass your userid
Trackierfluttersdk.setUserEmail("userEmail@gmail.com");
var userAdditonalDetail = Map<String, Object>();
userAdditonalDetail["phoneNumber"] = 9876453210;
Trackierfluttersdk.setUserAdditonalDetail(userAdditonalDetail);
var trackierId1 = await Trackierfluttersdk.getAd();
print('The value of trackierId1111 is: $trackierId1');
var trackierId2 = await Trackierfluttersdk.getAdID();
print('The value of trackierId is2222: $trackierId2');
// var trackierId = await Trackierfluttersdk.getTrackierId();
// print('The value of trackierId is: $trackierId');
Trackierfluttersdk.initializeSDK(trackerSDKConfig);
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion = await Trackierfluttersdk.platformVersion ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Trackier Flutter Sample App'),
),
body: Center(
child: Column(children: <Widget>[
Container(
margin: EdgeInsets.all(25),
// child: FlatButton(
// child: Text(
// 'Track Event',
// style: TextStyle(fontSize: 20.0),
// ),
// color: Colors.cyan,
// textColor: Colors.black,
// onPressed: _trackSimpleEvent,
// ),
),
Container(
margin: EdgeInsets.all(25),
// child: FlatButton(
// child: Text(
// 'Track Revenue Event',
// style: TextStyle(fontSize: 20.0),
// ),
// color: Colors.cyan,
// textColor: Colors.black,
// onPressed: _trackRevenueEvent,
// ),
),
]))),
);
}
void main() => runApp(MaterialApp.router(routerConfig: router));
final router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (_, __) => Scaffold(
appBar: AppBar(title: const Text('Home Screen')),
),
routes: [
GoRoute(
path: 'details',
builder: (_, __) => Scaffold(
appBar: AppBar(title: const Text('Details Screen')),
),
),
],
),
],
);
_trackSimpleEvent() {
TrackierEvent trackierEvent = new TrackierEvent("1CFfUn3xEY");
Trackierfluttersdk.setUserId("798e9w8ew09e8"); // Pass your userId here
Trackierfluttersdk.setUserName("abc");
Trackierfluttersdk.setUserPhone("6562127727");
Trackierfluttersdk.trackerEvent(trackierEvent);
}
_trackRevenueEvent() {
TrackierEvent trackierEvent = new TrackierEvent("1CFfUn3xEY");
trackierEvent.revenue = 10.0;
trackierEvent.currency = "INR";
trackierEvent.orderId = "orderID";
trackierEvent.param1 = "param1";
trackierEvent.param2 = "param2";
trackierEvent.discount = 2.0;
trackierEvent.couponCode = "test1";
Trackierfluttersdk.setUserName("abc");
Trackierfluttersdk.setUserPhone("6562127727");
trackierEvent.setEventValue("ev1", "eventValue1");
trackierEvent.setEventValue("ev2", 1);
Trackierfluttersdk.trackerEvent(trackierEvent);
}
}