appvestor_billing_stats 1.0.32 copy "appvestor_billing_stats: ^1.0.32" to clipboard
appvestor_billing_stats: ^1.0.32 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/ads/ad_format.dart' as billingAdFormat;
import 'package:appvestor_billing_stats/ads/ad_impression_provider.dart';
import 'package:appvestor_billing_stats/ads/applovin_ad_provider.dart';
import 'package:appvestor_billing_stats/ads/custom_ad_provider.dart';
import 'package:appvestor_billing_stats/ads/google_ad_provider.dart';
import 'package:appvestor_billing_stats/appvestor_billing_stats.dart';
import 'package:appvestor_billing_stats/attribution/attribution_data_type.dart';
import 'package:appvestor_billing_stats/events/events.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:applovin_max/applovin_max.dart';
import 'package:purchases_flutter/purchases_flutter.dart';

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> {
  @override
  @override
  void initState() {
    super.initState();
    AppvestorBillingStats.initialize();
    AppvestorBillingStats.setAccountId(acId: "your_account_id");
    AppvestorBillingStats.setAppId(apId: "your_ap_id");
    AppvestorBillingStats.firebaseEvents.listen((event) {
      debugPrint(
        "🔥 Appvestor Firebase Event: ${event['eventName']} -> ${event['payload']}",
      );
    });
    AppvestorBillingStats.dispatchAdImpressionAppLovin(
      AppLovinImpressionProvider(
        adUnitId: "ueid",
        adRevenue: 3.0,
        adFormat: "Banner",
        precision: "rffjk",
        networkName: "Applovin",
      ),
    );
    AppvestorBillingStats.dispatchAdImpressionGoogleAds(
      GoogleAdImpressionProvider(
        adUnitId: "tgj",
        valueMicros: 0.16,
        adFormat: billingAdFormat.AdFormat.banner,
        currencyCode: "USD",
        precisionType: 2,
        adSourceName: "Google",
      ),
    );
    AppvestorBillingStats.dispatchAdImpressionCustom(
      CustomAdImpressionProvider(
        adUnitId: "fjnhjg",
        value: 4.9,
        adFormat: billingAdFormat.AdFormat.banner,
        currencyCode: "EUR",
        precisionType: "djfh",
        adSourceName: "Custom",
      ),
    );
  }

  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: AdImpressionProvider.GAM,
                );
              }),

              _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"}',
                );
              }),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
0
points
260
downloads

Publisher

verified publisherappvestor.com

Weekly Downloads

Flutter SDK wrapper for Appvestor Android and iOS stats framework

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on appvestor_billing_stats

Packages that implement appvestor_billing_stats