adgydeflutterplugins 4.1.16
adgydeflutterplugins: ^4.1.16 copied to clipboard
AdGyde Flutter SDK
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:adgydeflutterplugins/adgydeflutterplugin.dart';
import 'package:adgydeflutterplugin_example/countingevent.dart';
import 'package:adgydeflutterplugin_example/uniqueevent.dart';
import 'package:adgydeflutterplugin_example/UserDetails.dart';
import 'package:adgydeflutterplugin_example/UserProfile.dart';
void main() {
//runApp(const MyApp());
runApp(MaterialApp(home:MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final adgydesinstance = Adgydeflutterplugin();
@override
void initState() {
super.initState();
adgydesinstance.init("Your_App_Key", "Organic");
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await adgydesinstance.getPlatformVersion() ?? '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) {
int number=0;
return Scaffold(
appBar: new AppBar(
title: new Text("AdGyde Sdk Example"),
),
body:
Center(
child: Column(
children: <Widget>[
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed: _simpleButtonClick,
child: new Text("SimpleEvent"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
//padding: const EdgeInsets.all(8.0),
onPressed:(){Navigator.push(context, MaterialPageRoute(builder: (context) => CountingEvent()),);
print("onPressCounting");},
child: new Text("CountingEvent"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
//padding: const EdgeInsets.all(8.0),
onPressed:_computingButtonClick,
child: new Text("ComputingEvent"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
//padding: const EdgeInsets.all(8.0),
onPressed:() {Navigator.push(context, MaterialPageRoute(builder: (context) => UniqueEvent()),);
print("onPressUnique");},
child: new Text("Unique Event"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed:_revenueButtonClick,
child: new Text("Revenue"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed:_AddScreen1,
child: new Text("AddScreen1"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed:_removeScreen1,
child: new Text("RemoveScreen1"),
),
/* new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed:(){Navigator.push(context, MaterialPageRoute(builder: (context) => UserDetails()),);},
child: new Text("UserDetail"),
),
new RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed:(){Navigator.push(context, MaterialPageRoute(builder: (context) => UserProfile()),);},
child: new Text("UserProfile"),
),*/
new RaisedButton(
child: Text('Call Native Method'),
onPressed: (){
adgydesinstance.getCampaignName();
},
),
Text( "Sanu Checked"),
],
)
)
);
}
/*
* Simple Event
* =============
* The below code is the example to pass a simple event to the AdGyde SDK.
* This event requires only 1 Parameter which is the Event ID.
*
* NOTE : Creating the Simple Event on Console with Event ID is Compulsory
*
*/
void _simpleButtonClick(){
adgydesinstance.simpleEvent("registration");
}
/*
* Computing Event
* =============
* The below code is the example to pass a Computing event to the AdGyde SDK.
* This event is used to get Sub-Category counting as per weightage of the Sub-Category
* Multiple values Can be passed for getting the computed values
* When user passes multiple values, the console shows the computed values of each value relatively
*
* NOTE : Creating the Computing Event on Console with Event ID, Parameter is Compulsory
*
*/
void _computingButtonClick(){
Map map =Map<String, dynamic>();
// First parameter is event name and second is value name which will be accumulated.
map={"offerlist":"50%Off"};
// Second parameter is the value for its value name. Value must be integer type.
map={"50%off":"1000rs"};
// Trigger event where first parameter is event_id
adgydesinstance.computingEvent("computing_event", map);
}
/*
* Revenue Event
* =============
* The below code is the example to pass a Revenue event to the AdGyde SDK.
* This event is useful to track revenue generated by the user in-app.
* Unit of the currency need not be passed, by default revenue is calculated in INR (Indian Rupees)
*
* NOTE : There is no Need to create the Revenue Event on Console
*
*/
void _revenueButtonClick(){
adgydesinstance.revenueEvent(70);
}
void _AddScreen1() {
adgydesinstance.setCurrentScreen("AddScreen1");
}
void _removeScreen1(){
adgydesinstance.removeCurrentScreen("AddScreen1");
}
}