-
Notifications
You must be signed in to change notification settings - Fork 298
/
main.dart
84 lines (82 loc) · 2.66 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import 'package:facebook_app_events/facebook_app_events.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
static final facebookAppEvents = FacebookAppEvents();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FutureBuilder(
future: facebookAppEvents.getAnonymousId(),
builder: (context, snapshot) {
final id = snapshot.data ?? '???';
return Text('Anonymous ID: $id');
},
),
MaterialButton(
child: Text("Click me!"),
onPressed: () {
facebookAppEvents.logEvent(
name: 'button_clicked',
parameters: {
'button_id': 'the_clickme_button',
},
);
},
),
MaterialButton(
child: Text("Set user data"),
onPressed: () {
facebookAppEvents.setUserData(
email: 'opensource@oddbit.id',
firstName: 'Oddbit',
dateOfBirth: '2019-10-19',
city: 'Denpasar',
country: 'Indonesia',
);
},
),
MaterialButton(
child: Text("Test logAddToCart"),
onPressed: () {
facebookAppEvents.logAddToCart(
id: '1',
type: 'product',
price: 99.0,
currency: 'TRY',
);
},
),
MaterialButton(
child: Text("Test purchase!"),
onPressed: () {
facebookAppEvents.logPurchase(amount: 1, currency: "USD");
},
),
MaterialButton(
child: Text("Enable advertise tracking!"),
onPressed: () {
facebookAppEvents.setAdvertiserTracking(enabled: true);
},
),
MaterialButton(
child: Text("Disabled advertise tracking!"),
onPressed: () {
facebookAppEvents.setAdvertiserTracking(enabled: false);
},
),
],
),
),
),
);
}
}