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:
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.
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":
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
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With