appier_flutter 2.5.0-dev.1 appier_flutter: ^2.5.0-dev.1 copied to clipboard
Flutter Plugin for Appier Enterprise Solutions. This plugin is intended to be used by Appier's customers.
import 'package:appier_flutter/appier_flutter.dart';
import 'package:flutter/material.dart';
import 'aideal/pagetypes.dart';
import 'screens/navigation_screen.dart';
void main() {
runApp(MaterialApp(
title: 'Appier Demo',
initialRoute: '/',
routes: {
'/': (context) => MainApp(),
'/second': (context) => FeedbackPage(),
NavigationPage.routeName: (context) => NavigationPage(),
},
));
}
class MainApp extends StatefulWidget {
const MainApp({Key? key}) : super(key: key);
@override
_MainAppState createState() => _MainAppState();
}
// add your app id before running in iOS
const appId = '<your_AppId>';
// add your app group before running in iOS
const appGroup = '<your_app_group>';
const appUniversalLink = 'universal-link';
class _MainAppState extends State<MainApp> {
@override
void initState() {
super.initState();
AppierFlutter.configure(appId, appGroup: appGroup, isDev: true);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Plugin example app'),
),
body: Center(
child: ListView(
padding: EdgeInsets.all(8),
children: <Widget>[
Text(
'AiQUA',
style: TextStyle(
fontSize: 20,
height: 1.4,
color: Colors.teal[200],
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.logEvent(
'product_viewed',
parameters: <String, dynamic>{
'param1': 2,
'param2': null,
'param3': 'appier',
},
);
},
child: Text('Log Event - product_viewed'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.logEvent(
'product_add_to_cart',
parameters: <String, dynamic>{
'param1': 2,
'param2': null,
'param3': 'appier',
},
);
},
child: Text('Log Event - product_add_to_cart'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.logEvent(
'product_purchased',
parameters: <String, dynamic>{
'param1': 2,
'param2': null,
'param3': 'appier',
},
vts: 100,
vtsCurr: 'USD',
);
},
child: Text('Log Event - product_purchased'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setUniversalLinkDomains([]);
AppierFlutter.setUniversalLinkDomains([appUniversalLink]);
},
child: Text('Set UniversalLinkDomains - iOS only'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: AppierFlutter.flush,
child: Text('flush log immediately'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setUserId('');
AppierFlutter.setUserId('0123456789');
},
child: Text('Set UserId'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setName('');
AppierFlutter.setName('tester');
},
child: Text('Set Name'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setFirstName('');
AppierFlutter.setFirstName('Gary');
},
child: Text('Set FirstName'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setLastName('');
AppierFlutter.setLastName('Wu');
},
child: Text('Set LastName'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setCity('');
AppierFlutter.setCity('London');
},
child: Text('Set City'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setEmail('');
AppierFlutter.setEmail('test.test@gmail.com');
},
child: Text('Set Email'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setPhoneNumber('');
AppierFlutter.setPhoneNumber('028865252');
},
child: Text('Set PhoneNumber'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setDayOfBirth(0);
AppierFlutter.setDayOfBirth(29);
},
child: Text('Set DayOfBirth'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setMonthOfBirth(0);
AppierFlutter.setMonthOfBirth(12);
},
child: Text('Set MonthOfBirth'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setYearOfBirth(12);
AppierFlutter.setYearOfBirth(0);
},
child: Text('Set YearOfBirth'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setCustomKey('Weight', 100);
AppierFlutter.setCustomKey('NickName', false);
AppierFlutter.setCustomKey('Height', 169.9);
AppierFlutter.setCustomKey('District', 'XinYi');
},
child: Text('Set CustomKeyValue'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setAttributionWindow(100);
},
child: Text('Set AttributionWindow'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
AppierFlutter.setClickAttributionWindow(100);
},
child: Text('Set ClickAttributionWindow'),
),
),
Text(
'AiDeal',
style: TextStyle(
fontSize: 20,
height: 1.4,
color: Colors.teal[200],
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Log Conversion'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Log Add to Cart'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Log Redeem Coupon'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Enable Data Collection'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Disable Data Collection'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Clear Storage'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[100],
onPrimary: Colors.black,
),
onPressed: () {
// TODO(Derek): call aideal API
},
child: Text('Simulate Campaign Event'),
),
),
SizedBox(
height: 44,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.teal[200],
onPrimary: Colors.black,
),
onPressed: () {
Navigator.pushNamed(context, NavigationPage.routeName,
arguments: NavigatePageArgs(PageType.top));
},
child: Text('Nativations'),
),
)
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
Navigator.pushNamed(context, '/second');
},
backgroundColor: Colors.yellow,
child: Icon(Icons.feedback),
),
),
);
}
}
class FeedbackPage extends StatelessWidget {
const FeedbackPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Feedback Page'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
AppierFlutter.logEvent('feedback');
},
child: Text('Log Feedback Event'),
),
),
);
}
}