Skip to content

Commit a1dd230

Browse files
committed
fix(ads): prevent interstitial ads from being dismissed by tapping outside
- Add 'await' keyword to showDialog calls for better async handling - Set 'barrierDismissible' to false in both _showLocalAd and _showDemoAd - Improve code comments for clarity
1 parent f754f0c commit a1dd230

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/ads/interstitial_ad_manager.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,17 +267,21 @@ class InterstitialAdManager {
267267

268268
Future<void> _showLocalAd(BuildContext context, InterstitialAd ad) async {
269269
if (ad.adObject is! LocalInterstitialAd) return;
270+
// Await the result of showDialog, which completes when the dialog is popped.
270271
await showDialog<void>(
271272
context: context,
273+
barrierDismissible: false, // Prevent dismissing by tapping outside
272274
builder: (_) => LocalInterstitialAdDialog(
273275
localInterstitialAd: ad.adObject as LocalInterstitialAd,
274276
),
275277
);
276278
}
277279

278280
Future<void> _showDemoAd(BuildContext context) async {
281+
// Await the result of showDialog, which completes when the dialog is popped.
279282
await showDialog<void>(
280283
context: context,
284+
barrierDismissible: false, // Prevent dismissing by tapping outside
281285
builder: (_) => const DemoInterstitialAdDialog(),
282286
);
283287
}

0 commit comments

Comments
 (0)