flutter_admob_app_open 1.1.3 flutter_admob_app_open: ^1.1.3 copied to clipboard
Admob App Open ads for flutter
import 'package:flutter/material.dart';
import 'package:flutter_admob_app_open/flutter_admob_app_open.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
/// Replace your admob app open ad unit id
final appAppOpenAdUnitId = FlutterAdmobAppOpen.testAppOpenAdId;
/// Init MobileAds and more configs
await MobileAds.instance.initialize().then((value) {
MobileAds.instance.updateRequestConfiguration(
//Add more configs
RequestConfiguration(testDeviceIds: []),
);
});
AdRequestAppOpen targetingInfo = AdRequestAppOpen(
keywords: <String>['flutterio', 'beautiful apps'],
contentUrl: 'https://flutter.io',
nonPersonalizedAds: true,
);
/// Init App Open Ads
await FlutterAdmobAppOpen.instance.initialize(
appAppOpenAdUnitId: appAppOpenAdUnitId,
targetingInfo: targetingInfo,
);
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on'),
),
),
);
}
}