Skip to content

Commit 4937a39

Browse files
committed
fix(ads): prevent native ad double dispose
Remove ad.dispose() call in onAdClosed to avoid premature disposal and potential crashes. The ad object is now disposed by AdmobNativeAdWidget when it is removed from the widget tree, preventing double dispose.
1 parent 7f88feb commit 4937a39

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/ads/admob_ad_provider.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ class AdMobAdProvider implements AdProvider {
119119
},
120120
onAdClosed: (ad) {
121121
_logger.info('Native Ad closed.');
122-
ad.dispose();
122+
// The ad object is now disposed by the AdmobNativeAdWidget (StatefulWidget)
123+
// when it is removed from the widget tree. Removing this dispose call
124+
// here prevents premature disposal and potential crashes.
123125
},
124126
onAdOpened: (ad) {
125127
_logger.info('Native Ad opened.');

0 commit comments

Comments
 (0)