Skip to content

Commit b867d53

Browse files
committed
refactor(ads): remove obsolete ad disposal comments from AdMobAdProvider
Removed comments related to ad disposal from the `onAdFailedToLoad` and `onTimeout` callbacks in `AdMobAdProvider`. Since the ad lifecycle is now exclusively managed by the `InlineAdCacheService`, this disposal logic (and the comments referring to it) is no longer relevant in the provider. This change clarifies the provider's role, which is solely to load ads, not to manage their disposal on failure.
1 parent a9d2e3a commit b867d53

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/ads/admob_ad_provider.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ class AdMobAdProvider implements AdProvider {
8888
},
8989
onAdFailedToLoad: (ad, error) {
9090
_logger.severe('AdMobAdProvider: Native Ad failed to load: $error');
91-
// Ad disposal is now handled by InlineAdCacheService
91+
// On a failed load, we do not dispose the ad object. The ad object
92+
// is managed by the google_mobile_ads plugin and will be garbage
93+
// collected. Completing with null signals the failure to the
94+
// caller.
9295
completer.complete(null);
9396
},
9497
onAdClicked: (ad) {
@@ -120,7 +123,6 @@ class AdMobAdProvider implements AdProvider {
120123
const Duration(seconds: _adLoadTimeout),
121124
onTimeout: () {
122125
_logger.warning('AdMobAdProvider: Native ad loading timed out.');
123-
// Ad disposal is now handled by InlineAdCacheService
124126
completer.complete(null);
125127
return null;
126128
},
@@ -179,7 +181,10 @@ class AdMobAdProvider implements AdProvider {
179181
},
180182
onAdFailedToLoad: (ad, error) {
181183
_logger.severe('AdMobAdProvider: Banner Ad failed to load: $error');
182-
// Ad disposal is now handled by InlineAdCacheService
184+
// On a failed load, we do not dispose the ad object. The ad object
185+
// is managed by the google_mobile_ads plugin and will be garbage
186+
// collected. Completing with null signals the failure to the
187+
// caller.
183188
completer.complete(null);
184189
},
185190
onAdOpened: (ad) {
@@ -205,7 +210,6 @@ class AdMobAdProvider implements AdProvider {
205210
const Duration(seconds: _adLoadTimeout),
206211
onTimeout: () {
207212
_logger.warning('AdMobAdProvider: Banner ad loading timed out.');
208-
// Ad disposal is now handled by InlineAdCacheService
209213
completer.complete(null);
210214
return null;
211215
},

0 commit comments

Comments
 (0)