NativeGoogleads class

Main class for interacting with Google Mobile Ads.

This plugin provides native implementations for displaying interstitial and rewarded ads in Flutter applications.

Example:

final ads = NativeGoogleads.instance;
await ads.initialize(appId: 'your-app-id');
await ads.preloadInterstitialAd(adUnitId: 'your-ad-unit-id');
await ads.showInterstitialAd(adUnitId: 'your-ad-unit-id');

Properties

hashCode int
The hash code for this object.
no setterinherited
methodChannel MethodChannel
Provides access to the underlying method channel for advanced use cases.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

debugSetForceReleaseModeForValidation(bool? isRelease) → void
INTERNAL – test-only override for release-mode detection in validation.
disposeBannerAd(String bannerId) Future<bool>
Disposes a banner ad and releases its resources.
disposeNativeAd(String nativeAdId) Future<bool>
Disposes a native ad and releases its resources.
getPlatformVersion() Future<String?>
Gets the platform version string.
hideBannerAd(String bannerId) Future<bool>
Hides a banner ad.
initialize({String? appId}) Future<Map<String, dynamic>?>
Initializes the Google Mobile Ads SDK.
initializeWithConfig(AdConfig config) Future<Map<String, dynamic>?>
Initializes the Google Mobile Ads SDK with a configuration object.
isInterstitialReady(String adUnitId) Future<bool>
Returns whether an interstitial ad is ready for the given ad unit ID.
isRewardedReady(String adUnitId) Future<bool>
Returns whether a rewarded ad is ready for the given ad unit ID.
loadBannerAd({required String adUnitId, required BannerAdSize size, AdRequestConfig? requestConfig}) Future<String?>
Loads a banner ad.
loadNativeAd({required String adUnitId, AdRequestConfig? requestConfig, NativeAdMediaAspectRatio? mediaAspectRatio}) Future<String?>
Loads a native ad.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preloadInterstitialAd({required String adUnitId, AdRequestConfig? requestConfig}) Future<bool>
Preloads an interstitial ad for the given ad unit ID.
preloadRewardedAd({required String adUnitId, AdRequestConfig? requestConfig}) Future<bool>
Preloads a rewarded ad for the given ad unit ID.
setAdCallbacks({AdCallback? onAdDismissed, AdCallback? onAdShowed, AdErrorCallback? onAdFailedToShow, RewardCallback? onUserEarnedReward}) → void
Sets callbacks for ad lifecycle events.
setAdIdValidationPolicy({bool? disallowTestIdsInRelease, bool? strict}) → void
Configure validation policy for using Google's test ad unit IDs in release.
showBannerAd(String bannerId) Future<bool>
Shows a previously loaded banner ad.
showInterstitialAd({required String adUnitId}) Future<bool>
Shows a preloaded interstitial ad for the given ad unit ID.
showNativeAd(String nativeAdId) Future<bool>
Shows a previously loaded native ad.
showRewardedAd({required String adUnitId}) Future<bool>
Shows a preloaded rewarded ad for the given ad unit ID.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

instance NativeGoogleads
Singleton instance of NativeGoogleads.
no setter