highfivve_advertising 0.0.1+4 copy "highfivve_advertising: ^0.0.1+4" to clipboard
highfivve_advertising: ^0.0.1+4 copied to clipboard

A Flutter plugin to integrate Highfivve GmbH's native highfivve_advertising.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:highfivve_advertising/highfivve_advertising.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize the Highfivve SDK
  await HighfivveAdManager.instance.initialize(
    bundleName: 'com.example.app', // Replace with your app's bundle ID
    publisherCode: 'your-publisher-code', // Replace with your publisher code
  );

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Highfivve Ad Example',
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    final interstitialAd = HighfivveInterstitialAd();

    return Scaffold(
      appBar: AppBar(title: const Text('Highfivve Ad Example')),
      body: Column(
        children: [
          // Show a banner ad
          const HighfivveBannerAdWidget(
            position: 'banner_1',
            pageType: 'home',
          ),
          const Spacer(),
          ElevatedButton(
            onPressed: () async {
              await interstitialAd.load('interstitial_1', pageType: 'home');
              if (interstitialAd.isLoaded) {
                await interstitialAd.show();
              }
            },
            child: const Text('Show Interstitial Ad'),
          ),
        ],
      ),
    );
  }
}