appvestor_billing_stats 1.0.3
appvestor_billing_stats: ^1.0.3 copied to clipboard
Flutter SDK wrapper for Appvestor Android and iOS stats framework
example/lib/main.dart
import 'dart:io';
import 'package:appvestor_billing_stats/appvestor_billing_stats.dart';
import 'package:appvestor_billing_stats/attribution/AttributionDataType.dart';
import 'package:appvestor_billing_stats/events/events.dart';
import 'package:flutter/material.dart';
import 'dart:async';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Appvestor Stats Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Appvestor Stats SDK Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
@override
void initState() {
super.initState();
AppvestorBillingStats.setAcID(acId: "jfkl");
AppvestorBillingStats.setApId(apId: "dhfjkjhgf");
AppvestorBillingStats.initialize();
AppvestorBillingStats.firebaseEvents.listen((event) {
debugPrint("🔥 Appvestor Firebase Event: ${event['eventName']} -> ${event['payload']}");
});
}
Widget _buildButton(String title, VoidCallback onPressed) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton(onPressed: onPressed, child: Text(title)),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Center(
child: Column(
children: <Widget>[
const SizedBox(height: 20),
_buildButton("Dispatch Internal Event", () {
AppvestorBillingStats.dispatchEvent(
eventName: InternalEventKey.AD_CLICKED,
optionalParams: {'source': 'flutter_app'},
);
}),
_buildButton("Dispatch Ad Viewed", () {
AppvestorBillingStats.dispatchAdViewedEvent("banner_home");
}),
_buildButton("Dispatch Ad Clicked", () {
AppvestorBillingStats.dispatchAdClickedEvent("banner_home");
}),
_buildButton("Dispatch Revenue Event", () {
AppvestorBillingStats.dispatchCustomRevenueEvent(
eventName: "purchase_made",
value: 4.99,
currency: "USD",
);
}),
_buildButton("Dispatch Ad Impression", () {
AppvestorBillingStats.dispatchAdImpressionEvent(
value: 1.2,
currency: "USD",
adPlatform: "AdMob",
);
}),
_buildButton("Dispatch Attribution Data", () {
AppvestorBillingStats.dispatchAttributionData(
type: AttributionDataType.DEFERRED_DEEP_LINK,
data: {
'tracker_token': 'abc123',
'campaign': 'spring_launch',
},
);
}),
_buildButton("Report Purchase", () {
AppvestorBillingStats.reportPurchase(
'{"orderId":"GPA.1111-2222-3333-44444"}',
);
}),
],
),
),
),
);
}
}