getSmartBannerHeight function
The initial size of the banner is calculated on the height of the viewport. Due to ADMob banner refresh policies, in order to have a consistent behaviour, we should keep track of the current AD size and maintain it when the user rotates the screen, and update that value at every banner successful. For now, we will avoid this complexity and set the banner height to the maximum height that a banner could get on this device, forcing the use of the longest side as the base. see https://developers.google.com/admob/android/banner#smart_banners
Implementation
double getSmartBannerHeight(BuildContext context) {
MediaQueryData mediaScreen = MediaQuery.of(context);
double dpHeight = mediaScreen.orientation == Orientation.portrait
? mediaScreen.size.height
: mediaScreen.size.width;
double dim= 50.0;
if (dpHeight <= 400.0) {
dim= 32.0;
}
if (dpHeight >= 720.0) {
dim= 90.0;
}
// Tools.logCat("Device height: $dpHeight | Ads Height:$dim");
return dim;
}