googleads / admob-ads-in-flutter

Apache License 2.0
72 stars 36 forks source link

Nit: No need for container in banner ad example code #27

Open bitjunk opened 2 years ago

bitjunk commented 2 years ago

Current example code for invoking banner ad:

@override
Widget build(BuildContext context) {
  return Scaffold(
    ...
    body: SafeArea(
      child: Stack(
        children: [
          Center(
            ...
          ),
          // TODO: Display a banner when ready
          if (_bannerAd != null)
            Align(
              alignment: Alignment.topCenter,
// No need for container could be a SizedBox instead or maybe provide alignment inside the container. 
              child: Container(
                width: _bannerAd!.size.width.toDouble(),
                height: _bannerAd!.size.height.toDouble(),
                child: AdWidget(ad: _bannerAd!),
              ),
            ),
        ],
      ),
    ),
    ...
  );
}

Container could be a sized box or maybe provide alignment in the container.