google_mobile_ads_adapter 1.1.2 copy "google_mobile_ads_adapter: ^1.1.2" to clipboard
google_mobile_ads_adapter: ^1.1.2 copied to clipboard

An adapter package for the google_mobile_ads plugin, designed to simplify ads integration and management.

google_mobile_ads_adapter #

An adapter package for the google_mobile_ads plugin, designed to simplify ads integration and management.

Description #

google_mobile_ads_adapter provides a comprehensive set of utilities to manage ads using the Google Mobile Ads SDK in Flutter applications. It includes predefined ad adapters, mediation adapters, and an ads controller to easily integrate and manage ads in your Flutter projects.

Usage #

Ads Controller #

The AdsController class provides methods to initialize and load ads using different adapters.

import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:google_mobile_ads_adapter/google_mobile_ads_adapter.dart';

void main() {
  // Initialize the AdsController
  AdsController adsController = AdsController();
  adsController.init();

  // Choose an ad to load
  InterstitialAdAdapter interstitialAdAdapter = InterstitialAdAdapter('AD_ID');

  // Load the ad
  InterstitialAd? ad =
      await adsController.load<InterstitialAd>(interstitialAdAdapter);

  // Show the ad
  ad?.show();
}

Mediation Adapters

To use a mediation provider, implement your own adapter by extending MediationAdapter. For example:

import 'package:google_mobile_ads_adapter/google_mobile_ads_adapter.dart';
import 'package:gma_mediation_liftoffmonetize/gma_mediation_liftoffmonetize.dart';

class LiftoffmonetizeAdapter extends MediationAdapter {
  final GmaMediationLiftoffmonetize _mediation;

  LiftoffmonetizeAdapter({
    GmaMediationLiftoffmonetize? mediation,
  }) : _mediation = mediation ?? GmaMediationLiftoffmonetize();

  @override
  Future<void> init() async {
    await super.init();
    await _mediation.setGDPRStatus(true, '1.0.0');
    await _mediation.setCCPAStatus(true);
  }
}

Then provide your adapter to the AdsController:

void main() async {
  AdsController adsController = AdsController(
    mediationAdapters: [
      LiftoffmonetizeAdapter(),
    ],
  );
  await adsController.init();
}

Issues and feedback #

Please report any issue, bug or feature request in our issue tracker

2
likes
160
points
141
downloads

Publisher

verified publisherxeertz.com

Weekly Downloads

An adapter package for the google_mobile_ads plugin, designed to simplify ads integration and management.

Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, google_mobile_ads, logging

More

Packages that depend on google_mobile_ads_adapter