display interstitial ads automatically after 20 sec in flutter code example
Example 1: showing ads every x seconds flutter
import 'dart:async';
Timer _timerForInter;
@override
void initState() {
_timerForInter = Timer.periodic(Duration(seconds: 20), (result) {
_interstitialAd = createInterstitialAd()..load();
});
super.initState();
}
@override
void dispose() {
_timerForInter.cancel();
_interstitialAd.dispose();
super.dispose();
}
Example 2: how to show ad every second flutter
import 'dart:async';
Timer _timerForInter;
@override
void initState() {
_timerForInter = Timer.periodic(Duration(seconds: 20), (result) {
_interstitialAd = createInterstitialAd()..load();
});
super.initState();
}
@override
void dispose() {
_timerForInter.cancel();
_interstitialAd.dispose();
super.dispose();
}