Advertisement
Zanak

ad state

Jul 28th, 2021
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.08 KB | None | 0 0
  1.  
  2.  
  3. import 'dart:io';
  4.  
  5. import 'package:google_mobile_ads/google_mobile_ads.dart';
  6.  
  7. class AdState  {
  8.  
  9.   Future<InitializationStatus> initialization;
  10.  
  11.   AdState(this.initialization);
  12.   String get bannerAdUnitId => Platform.isAndroid ? "ca-app-pub-3940256099942544/6300978111" : "ca-app-pub-3940256099942544/6300978111";
  13.  
  14.   BannerAdListener get adListener => _adListener;
  15.  
  16.   BannerAdListener _adListener = BannerAdListener(
  17.     // Called when an ad is successfully received.
  18.     onAdLoaded: (Ad ad) => print('Ad loaded.'),
  19.     // Called when an ad request failed.
  20.     onAdFailedToLoad: (Ad ad, LoadAdError error) {
  21.       // Dispose the ad here to free resources.
  22.       ad.dispose();
  23.       print('Ad failed to load: $error');
  24.     },
  25.     // Called when an ad opens an overlay that covers the screen.
  26.     onAdOpened: (Ad ad) => print('Ad opened.'),
  27.     // Called when an ad removes an overlay that covers the screen.
  28.     onAdClosed: (Ad ad) => print('Ad closed.'),
  29.     // Called when an impression occurs on the ad.
  30.     onAdImpression: (Ad ad) => print('Ad impression.'),
  31.   );
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement