title: Problem with AdWidget in Flutter Dart (AdWidget requires Ad.load to be called before...)
body: <p>I get the error in the picture from the code that follows.</p>
  <p>The app is useing WordPress REST API to get titles and pics from a wp site.
  Then puts them in Cards. All works as intended until I try to show an ad in bottomNavigationBar...</p>
  <p>I think the problem is that I'm trying to put the ad in FutureBuilder. But can't figure it out.</p>
  <p>Any thoughts?</p>
  <p><a href="https://i.stack.imgur.com/0yzmB.png" rel="nofollow noreferrer">AdWidget requires Ad.load to be called before AdWidget is inserted into the tree</a></p>
  <pre><code>
  // @dart=2.9
  // this downgrade is necessary because of the damn null safety
  
  import...
  
  void main() {
    WidgetsFlutterBinding.ensureInitialized();
    final initFuture = MobileAds.instance.initialize();
    final adState = AdState(initFuture);
  
    runApp(
      Provider.value(value: adState, builder: (context, child) =&gt; MyApp()),
    );
  }
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        theme: ThemeData(primarySwatch: Colors.yellow),
        home: MyHomePage(),
      );
    }
  }
  
  // some code...
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    BannerAd banner;
    bool _bannerIsLoaded = false;
  
    @override
    void didChangeDependencies() {
      super.didChangeDependencies();
      final adState = Provider.of&lt;AdState&gt;(context);
      adState.initialization.then((status) {
        setState(() {
          banner = BannerAd(
              size: AdSize.banner,
              adUnitId: adState.bannerAdUnitId,
              listener: BannerAdListener(onAdLoaded: (Ad ad) {
                print('$BannerAd loaded.');
                setState(() {
                  _bannerIsLoaded = true;
                });
              }),
              request: AdRequest());
          banner.load();
        });
      });
    }
  
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
  
  // some code...
  
              ),
            ])),
        body: Column(
            children: [
              Expanded(
                  child: FutureBuilder(
                      future: fetchWpPosts(),
                      builder: (context, snapshot) {
                        if (snapshot.hasData &amp;&amp; snapshot.data != null) {
                          return ListView.builder(
  
                            // some code...
  
                                          ])));
                            },
                          );
                        }
  
                        return Container(
                            color: Colors.black,
                            child: Center(
                              child: CircularProgressIndicator(strokeWidth: 5.0),
                            ));
                      }))
            ]),
        bottomNavigationBar: _bannerIsLoaded
            ? SizedBox(height: 50, child: AdWidget(ad: banner))
            : SizedBox(height: 50),
      );
    }
  }
  
  
  </code></pre>