showIntraAds function
dynamic
showIntraAds({
- required BuildContext context,
- Function? callback,
- bool isCompulsory = false,
Implementation
showIntraAds(
{required BuildContext context,
Function? callback,
bool isCompulsory = false}) async {
showProgressbarDialog(context);
Timer? timer = null;
timer = Timer(
Duration(milliseconds: _settings?.adSetting?.adsTimeout ?? 3000), () {
timer?.cancel();
Navigator.pop(context);
if (callback != null) {
callback();
}
});
loadIntraAds(
isCompulsory: isCompulsory,
onAdLoadedCallback: (isTrue) {
if (timer?.isActive == true) {
int remainingTime = isTrue
? (_settings?.adSetting?.adsLoadingTimeout ?? 1500) -
(timer?.tick ?? 0)
: 0;
if (remainingTime > 0) {
Future.delayed(
Duration(milliseconds: remainingTime),
() => {
if (timer?.isActive == true)
{
timer?.cancel(),
Navigator.pop(context),
_showInterstitialAd(callback)
}
});
} else {
timer?.cancel();
Navigator.pop(context);
_showInterstitialAd(callback);
}
}
});
}