AdmobUnitIDs class abstract

The abstract class that represents the manager of AdMob Unit ID.

1. What you need to override

By overriding the following abstract methods of this abstract class, you can easily manage and use AdMob's unit ID for debugging and releasing.

2. What you should use then

If you override the above abstract methods in a class that extends from this abstract class, basically no need to use the overridden methods directly, but use the following methods defined in this abstract class to get the unit ID depends on the application startup status.

The following methods check the application startup status, and returns the unit ID for testing when debugging, and returns the release unit ID implemented in concrete class extended this abstract class when releasing.

3. How to use in details

import 'package:admob_unit_ids/admob_unit_ids.dart';

/// The example class that demonstraits [AdmobUnitIDs].
class DemoAdmobUnitIDs extends AdmobUnitIDs {
 /// The singleton instance of [DemoAdmobUnitIDs].
 static final DemoAdmobUnitIDs _singletonInstance = DemoAdmobUnitIDs._internal();

 /// The internal default constructor.
 DemoAdmobUnitIDs._internal();

 /// Returns the singleton instance of [DemoAdmobUnitIDs].
 factory DemoAdmobUnitIDs.getInstance() => _singletonInstance;

 @override
 String get releaseAppOpen => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseBanner => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseInterstitial => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseInterstitialVideo => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseNativeAdvanced => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseNativeAdvancedVideo => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseRewarded => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';

 @override
 String get releaseRewardedInterstitial => Platform.isAndroid
     ? 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx'
     : 'ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx';
}

void main() {
 final AdmobUnitIDs admobUnitIDs = DemoAdmobUnitIDs.getInstance();

 // => Unit id for debugging or unit id for releasing.
 print(admobUnitIDs.appOpen);
 print(admobUnitIDs.banner);
 print(admobUnitIDs.interstitial);
 print(admobUnitIDs.interstitialVideo);
 print(admobUnitIDs.nativeAdvanced);
 print(admobUnitIDs.nativeAdvancedVideo);
 print(admobUnitIDs.rewarded);
 print(admobUnitIDs.rewardedInterstitial);
}

Constructors

AdmobUnitIDs()

Properties

appOpen String
Returns the unit id of app open.
no setter
Returns the unit id of banner.
no setter
hashCode int
The hash code for this object.
no setterinherited
interstitial String
Returns the unit id of interstitial.
no setter
interstitialVideo String
Returns the unit id of interstitial video.
no setter
nativeAdvanced String
Returns the unit id of native advanced.
no setter
nativeAdvancedVideo String
Returns the unit id of native advanced video.
no setter
releaseAppOpen String
Returns the release unit id of app open.
no setter
releaseBanner String
Returns the release unit id of banner.
no setter
releaseInterstitial String
Returns the release unit id of interstitial.
no setter
releaseInterstitialVideo String
Returns the release unit id of interstitial video.
no setter
releaseNativeAdvanced String
Returns the release unit id of native advanced.
no setter
releaseNativeAdvancedVideo String
Returns the release unit id of native advanced video.
no setter
releaseRewarded String
Returns the release unit id of rewarded.
no setter
releaseRewardedInterstitial String
Returns the release unit id of rewarded interstitial.
no setter
rewarded String
Returns the unit id of rewarded.
no setter
rewardedInterstitial String
Returns the unit id of rewarded interstitial.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

release → const bool
The flag that represents the execution mode of the application.