my_ads_manager 0.0.1
my_ads_manager: ^0.0.1 copied to clipboard
Simple ads manager package for personal use.
import 'package:flutter/material.dart';
import 'package:my_ads_manager/my_ads_manager.dart';
void main() async {
// Default - true
final config = AdsConfig(enabled: true);
final adapter = GoogleAdsAdapter();
final repo = AdsRepository(adapter, config);
runApp(MyApp(adsRepo: repo));
}
class MyApp extends StatelessWidget {
const MyApp({super.key, required this.adsRepo});
final AdsRepository adsRepo;
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'MyAdsManager Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: Scaffold(
appBar: AppBar(),
body: Column(
children: [
BannerAdView(
bannerControllerFuture: adsRepo.loadBanner(
"ca-app-pub-3940256099942544/9214589741", // test banner ad id
width: AdSizeConfig.banner.width,
height: AdSizeConfig.banner.height,
),
height: AdSizeConfig.banner.height.toDouble(),
),
const SizedBox(height: 16),
NativeAdViewWidget(
adUnitId: "ca-app-pub-3940256099942544/2247696110", // test id
adsRepo: adsRepo,
),
],
),
),
);
}
}