Initial commit

This commit is contained in:
St. Nebula
2026-04-23 23:58:59 -05:00
commit 47b9e3c159
257 changed files with 18913 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:flutter/foundation.dart';
import 'package:onsolgo/core/constants.dart';
class AdHandler {
static InterstitialAd? _interstitialAd;
static void loadInterstitialAd() {
if (kIsWeb) return; // Skip on PWA
InterstitialAd.load(
adUnitId: kInterstitialAdUnitId,
request: const AdRequest(),
adLoadCallback: InterstitialAdLoadCallback(
onAdLoaded: (ad) => _interstitialAd = ad,
onAdFailedToLoad: (error) => _interstitialAd = null,
),
);
}
static void showInterstitialAd(Function onAdClosed) {
if (kIsWeb || _interstitialAd == null) {
onAdClosed(); // If web or ad not ready, just open the chapter
return;
}
_interstitialAd!.fullScreenContentCallback = FullScreenContentCallback(
onAdDismissedFullScreenContent: (ad) {
ad.dispose();
loadInterstitialAd(); // Load next one
onAdClosed(); // Open the chapter
},
onAdFailedToShowFullScreenContent: (ad, error) {
ad.dispose();
onAdClosed();
},
);
_interstitialAd!.show();
_interstitialAd = null;
}
}