Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: Banner Ad Overlapping The Main Screen

I am doing a Flutter app and managed to show the AdMob banner ad, however the ad overlaps the bottom of my app's main screen:

enter image description here

By following this article, I managed to make the app screen's bottom properly displayed, but the persistentFooterButtons is sacrificed, which I think is not an ideal solution. enter image description here

I am thinking about putting the Scaffold object and a fixed height area into a column that is contained by a Center object, something similar to the following:

  @override
  Widget build(BuildContext context) {

    return new Center(
      child: new Column (
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          new Expanded (
              child:  _getScaffold(),
          ),
          new Expanded (
              child: new Container(height: 50.0,)
          )
        ],
      ),
    );
  }

But in this way I get the exception "A RenderFlex overflowed by 228 pixels on the bottom":

enter image description here

Anybody can show me how to build such layout? I want every component of my scaffold properly displayed, with a fixed height dummy footer that is ok to be overlapped by the Admob's banner ad.

Any help is much welcome.

Jimmy

like image 571
Wonderjimmy Avatar asked Feb 22 '18 18:02

Wonderjimmy


People also ask

What is the use of text banner in flutter?

It is somewhat similar to the debug banner what we are used to of seeing on the top-right corner on a flutter app in debug mode. It enables us to show a message or text on top of any other widget. Below we will see its implementation with the help of an example and all its properties.

How to implement overlay in flutter?

To implement Overlay in Flutter we need to know about two Flutter built-in classes OverlayEntry class a nd the OverlayState class. Vaguely speaking OverlayEntry is a place in an Overlay that can contain a widget. builder: Takes a widget builder.

What is the location of the banner widget in this flutter application?

Explanation: In this flutter application the Banner widget is child of ClipRect class which clips off the part that exceeds the box. The message in the banner is holding the text ‘20% off !!’, the color is red and the location is set to bottomStart.

How do I integrate Flutter with AdMob?

Set up the AdMob app and ad units Because Flutter is a multi-platform SDK, you need to add an app and ad units for both Android and iOS in AdMob. Note: If you want to follow the codelab instead of creating a new application and ad units on your own, go to the Use the test AdMob app and ad units section.


1 Answers

Also we can add some trick like bottomNavigationBar under the Scaffold

bottomNavigationBar: Container(
    height: 50.0,
    color: Colors.white,
  ),

This will take floating button up.

like image 165
Ishan Fernando Avatar answered Oct 29 '22 15:10

Ishan Fernando