title: How to show interstitial ads evry 20 seconds in flutter dart
body: <p>i have a problem implementing interstitial timed ads with flutter. i have implemented one option which shows ads when a button is clicked but i want to implement where it shows ad every 20 seconds.please help</p>
  
  <p>am using the code below i found online</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:firebase_admob/firebase_admob.dart';
  
  const String testDevice = 'MobileId';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
    static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
      testDevices: testDevice != null ? &lt;String&gt;[testDevice] : null,
      nonPersonalizedAds: true,
      keywords: &lt;String&gt;['Game', 'Mario'],
    );
  
    BannerAd _bannerAd;
    InterstitialAd _interstitialAd;
  
    BannerAd createBannerAd() {
      return BannerAd(
          adUnitId: BannerAd.testAdUnitId,
        //Change BannerAd adUnitId with Admob ID
          size: AdSize.banner,
          targetingInfo: targetingInfo,
          listener: (MobileAdEvent event) {
            print("BannerAd $event");
          });
    }
  
    InterstitialAd createInterstitialAd() {
      return InterstitialAd(
          adUnitId: InterstitialAd.testAdUnitId,
        //Change Interstitial AdUnitId with Admob ID
          targetingInfo: targetingInfo,
          listener: (MobileAdEvent event) {
            print("IntersttialAd $event");
          });
    }
  
    @override
    void initState() {
      FirebaseAdMob.instance.initialize(appId: BannerAd.testAdUnitId);
      //Change appId With Admob Id
      _bannerAd = createBannerAd()
        ..load()
        ..show();
      super.initState();
    }
  
    @override
    void dispose() {
      _bannerAd.dispose();
      _interstitialAd.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Flutter Demo',
        theme: ThemeData(),
        home: Scaffold(
          appBar: AppBar(
            title: Text("Demo App"),
          ),
          body: Center(
              child: RaisedButton(
            child: Text('Click on Ads'),
            onPressed: () {
              createInterstitialAd()
                ..load()
                ..show();
            },
          )),
        ),
      );
    }
  }
  </code></pre>
  
  <p>am using the flutter language and there are not many tutorials online yet because the community is still growing</p>