question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 AdMob inline banner is shown on iOS on top of the screen too (why?)

See original GitHub issue

Bug report

Describe the bug I inserted a AdMob inline banner in a listview like described in the official codelab. The test-mode-banner is shown right in the listview on android and iOS. But on iOS-device the banner is shown too on the top of my screen and overlays my listview.

Steps to reproduce

This the code of my banner-widget:

import '../widgets/progress.dart';
import 'package:flutter/material.dart';
import '../google_mobile_ads/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../pages/home_page.dart';

class AdGrid03GoogleBanner extends StatefulWidget {
  int bannerWidth;
  int bannerHeight;

  AdGrid03GoogleBanner({this.bannerHeight, this.bannerWidth});

  @override
  _AdGrid03GoogleBannerState createState() => _AdGrid03GoogleBannerState();
}

class _AdGrid03GoogleBannerState extends State<AdGrid03GoogleBanner> {
  BannerAd _ad;
  bool _isAdLoaded = false;
  int bannerWidth;
  int bannerHeight;

  @override
  void initState() {
    super.initState();
    bannerWidth = widget.bannerWidth;
    bannerHeight = widget.bannerHeight;
    AdSize adSize = AdSize(width: bannerWidth, height: bannerHeight);

    _ad = BannerAd(
      adUnitId: AdHelper.bannerAdUnitId,
      //size: AdSize.banner,
      size: adSize,
      request: AdRequest(),
      listener: AdListener(
        onAdLoaded: (_) {
          setState(() {
            _isAdLoaded = true;
          });
        },
        onAdFailedToLoad: (_, error) {
          print('Ad load failed (code=${error.code} message=${error.message})');
        },
      ),
    );

    // TODO: Load an ad
    _ad.load();
  }

  @override
  void dispose() {
    // TODO: Dispose a BannerAd object
    _ad?.dispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: _isAdLoaded ? AdWidget(ad: _ad) : circularProgress(),
      width: _ad.size.width.toDouble(),
      height: double.parse((bannerHeight * 1.5).toString()),
      alignment: Alignment.center,
    );
  }
}

Expected behavior

I don’t expected that the banner is shown on the top of my screen too.


Additional context

Add any other context about the problem here.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
flutter doctor -v
[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale de-DE)
    • Flutter version 2.0.2 at /Users/michael/Documents/Developer/flutter
    • Framework revision 8962f6dc68 (9 days ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/michael/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google
    Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • iPhone 12 Pro Max (mobile) • F2E4F560-8466-43F3-A33B-41039F6F4F8E • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4
      (simulator)

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
flutter pub deps
Dart SDK 2.12.1
Flutter SDK 2.0.2
myApp 1.0.0+1
|-- animator 3.0.0
|   |-- flutter...
|   '-- states_rebuilder 4.0.0+1
|       |-- collection...
|       '-- flutter...
|-- cached_network_image 3.0.0-nullsafety
|   |-- flutter...
|   |-- flutter_cache_manager 3.0.0-nullsafety.1
|   |   |-- clock...
|   |   |-- collection...
|   |   |-- file 6.1.0
|   |   |   |-- meta...
|   |   |   '-- path...
|   |   |-- flutter...
|   |   |-- http...
|   |   |-- image...
|   |   |-- path...
|   |   |-- path_provider...
|   |   |-- pedantic...
|   |   |-- rxdart...
|   |   |-- sqflite 2.0.0+2
|   |   |   |-- flutter...
|   |   |   |-- path...
|   |   |   '-- sqflite_common 2.0.0+2
|   |   |       |-- meta...
|   |   |       |-- path...
|   |   |       '-- synchronized 3.0.0
|   |   '-- uuid...
|   '-- octo_image 1.0.0-nullsafety.1
|       |-- flutter...
|       '-- flutter_blurhash 0.5.4-nullsafety.0
|           |-- flutter...
|           |-- meta...
|           '-- pedantic...
|-- cloud_firestore 1.0.1
|   |-- cloud_firestore_platform_interface 4.0.0
|   |   |-- collection...
|   |   |-- firebase_core...
|   |   |-- flutter...
|   |   |-- meta...
|   |   '-- plugin_platform_interface...
|   |-- cloud_firestore_web 1.0.1
|   |   |-- cloud_firestore_platform_interface...
|   |   |-- firebase_core...
|   |   |-- firebase_core_web...
|   |   |-- flutter...
|   |   |-- flutter_web_plugins...
|   |   '-- js...
|   |-- firebase_core...
|   |-- firebase_core_platform_interface...
|   |-- flutter...
|   '-- meta...
|-- cupertino_icons 1.0.2
|-- firebase_analytics 7.1.1
|   |-- firebase_analytics_platform_interface 1.1.0
|   |   |-- flutter...
|   |   '-- meta...
|   |-- firebase_analytics_web 0.2.0+1
|   |   |-- firebase 9.0.0
|   |   |   |-- http...
|   |   |   |-- http_parser...
|   |   |   '-- js...
|   |   |-- firebase_analytics_platform_interface...
|   |   |-- flutter...
|   |   |-- flutter_web_plugins...
|   |   '-- meta...
|   |-- firebase_core...
|   |-- flutter...
|   '-- meta...
|-- firebase_auth 1.0.1
|   |-- firebase_auth_platform_interface 4.0.0
|   |   |-- firebase_core...
|   |   |-- flutter...
|   |   |-- meta...
|   |   '-- plugin_platform_interface...
|   |-- firebase_auth_web 1.0.2
|   |   |-- firebase_auth_platform_interface...
|   |   |-- firebase_core...
|   |   |-- firebase_core_web...
|   |   |-- flutter...
|   |   |-- flutter_web_plugins...
|   |   |-- http_parser...
|   |   |-- intl...
|   |   |-- js...
|   |   '-- meta...
|   |-- firebase_core...
|   |-- firebase_core_platform_interface...
|   |-- flutter...
|   '-- meta...
|-- firebase_core 1.0.1
|   |-- firebase_core_platform_interface 4.0.0
|   |   |-- flutter...
|   |   |-- meta...
|   |   '-- plugin_platform_interface 2.0.0
|   |       '-- meta...
|   |-- firebase_core_web 1.0.1
|   |   |-- firebase_core_platform_interface...
|   |   |-- flutter...
|   |   |-- flutter_web_plugins...
|   |   |-- js 0.6.3
|   |   '-- meta...
|   |-- flutter...
|   '-- meta...
|-- firebase_messaging 9.0.0
|   |-- firebase_core...
|   |-- firebase_core_platform_interface...
|   |-- firebase_messaging_platform_interface 2.0.0
|   |   |-- firebase_core...
|   |   |-- flutter...
|   |   |-- meta...
|   |   '-- plugin_platform_interface...
|   |-- firebase_messaging_web 1.0.1
|   |   |-- firebase_core...
|   |   |-- firebase_core_web...
|   |   |-- firebase_messaging_platform_interface...
|   |   |-- flutter...
|   |   |-- flutter_web_plugins...
|   |   |-- js...
|   |   '-- meta...
|   |-- flutter...
|   '-- meta...
|-- firebase_storage 8.0.0
|   |-- firebase_core...
|   |-- firebase_core_platform_interface...
|   |-- firebase_storage_platform_interface 2.0.0
|   |   |-- collection...
|   |   |-- firebase_core...
|   |   |-- flutter...
|   |   |-- meta...
|   |   '-- plugin_platform_interface...
|   |-- firebase_storage_web 1.0.1
|   |   |-- async...
|   |   |-- firebase_core...
|   |   |-- firebase_core_web...
|   |   |-- firebase_storage_platform_interface...
|   |   |-- flutter...
|   |   |-- flutter_web_plugins...
|   |   |-- http...
|   |   |-- js...
|   |   '-- meta...
|   '-- flutter...
|-- flutter 0.0.0
|   |-- characters 1.1.0
|   |-- collection 1.15.0
|   |-- meta 1.3.0
|   |-- sky_engine 0.0.99
|   |-- typed_data 1.3.0
|   |   '-- collection...
|   '-- vector_math 2.1.0
|-- flutter_google_places_hoc081098 1.0.0-nullsafety.0
|   |-- collection...
|   |-- flutter...
|   |-- google_api_headers 1.0.0
|   |   |-- flutter...
|   |   '-- package_info 2.0.0
|   |       '-- flutter...
|   |-- google_maps_webservice...
|   |-- http...
|   |-- listenable_stream 1.0.0-nullsafety.1
|   |   |-- flutter...
|   |   '-- rxdart...
|   '-- rxdart 0.26.0
|-- flutter_localizations 0.0.0
|   |-- characters...
|   |-- clock 1.1.0
|   |-- collection...
|   |-- flutter...
|   |-- intl 0.17.0
|   |   |-- clock...
|   |   '-- path...
|   |-- meta...
|   |-- path 1.8.0
|   |-- typed_data...
|   '-- vector_math...
|-- flutter_spinkit 5.0.0
|   '-- flutter...
|-- flutter_test 0.0.0
|   |-- async 2.5.0
|   |   '-- collection...
|   |-- boolean_selector 2.1.0
|   |   |-- source_span...
|   |   '-- string_scanner...
|   |-- characters...
|   |-- charcode 1.2.0
|   |-- clock...
|   |-- collection...
|   |-- fake_async 1.2.0
|   |   |-- clock...
|   |   '-- collection...
|   |-- flutter...
|   |-- matcher 0.12.10
|   |   '-- stack_trace...
|   |-- meta...
|   |-- path...
|   |-- source_span 1.8.0
|   |   |-- charcode...
|   |   |-- collection...
|   |   |-- path...
|   |   '-- term_glyph...
|   |-- stack_trace 1.10.0
|   |   '-- path...
|   |-- stream_channel 2.1.0
|   |   '-- async...
|   |-- string_scanner 1.1.0
|   |   |-- charcode...
|   |   '-- source_span...
|   |-- term_glyph 1.2.0
|   |-- test_api 0.2.19
|   |   |-- async...
|   |   |-- boolean_selector...
|   |   |-- collection...
|   |   |-- matcher...
|   |   |-- meta...
|   |   |-- path...
|   |   |-- source_span...
|   |   |-- stack_trace...
|   |   |-- stream_channel...
|   |   |-- string_scanner...
|   |   '-- term_glyph...
|   |-- typed_data...
|   '-- vector_math...
|-- geocoder 0.2.1
|   |-- flutter...
|   '-- meta...
|-- geolocator 7.0.1
|   |-- flutter...
|   |-- geolocator_platform_interface 2.0.0
|   |   |-- flutter...
|   |   |-- meta...
|   |   |-- plugin_platform_interface...
|   |   '-- vector_math...
|   '-- geolocator_web 2.0.1
|       |-- flutter...
|       |-- flutter_web_plugins...
|       '-- geolocator_platform_interface...
|-- google_maps_webservice 0.0.20-nullsafety.2
|   |-- http...
|   |-- json_annotation 4.0.0
|   '-- meta...
|-- google_mobile_ads 0.11.0+4
|   |-- flutter...
|   '-- meta...
|-- http 0.13.0
|   |-- http_parser 4.0.0
|   |   |-- charcode...
|   |   |-- collection...
|   |   |-- source_span...
|   |   |-- string_scanner...
|   |   '-- typed_data...
|   |-- meta...
|   |-- path...
|   '-- pedantic 1.11.0
|-- image 3.0.1
|   |-- archive 3.1.2
|   |   |-- crypto...
|   |   '-- path...
|   |-- meta...
|   '-- xml 5.0.2
|       |-- collection...
|       |-- meta...
|       '-- petitparser 4.0.2
|           '-- meta...
|-- image_picker 0.7.2+1
|   |-- flutter...
|   |-- flutter_plugin_android_lifecycle 2.0.0
|   |   '-- flutter...
|   '-- image_picker_platform_interface 2.0.1
|       |-- flutter...
|       |-- http...
|       |-- meta...
|       '-- plugin_platform_interface...
|-- material_design_icons_flutter 4.0.5955
|   '-- flutter...
|-- path_provider 2.0.1
|   |-- flutter...
|   |-- path_provider_linux 2.0.0
|   |   |-- flutter...
|   |   |-- path...
|   |   |-- path_provider_platform_interface...
|   |   '-- xdg_directories 0.2.0
|   |       |-- meta...
|   |       |-- path...
|   |       '-- process 4.1.0
|   |           |-- file...
|   |           |-- path...
|   |           '-- platform...
|   |-- path_provider_macos 2.0.0
|   |   '-- flutter...
|   |-- path_provider_platform_interface 2.0.1
|   |   |-- flutter...
|   |   |-- meta...
|   |   |-- platform 3.0.0
|   |   '-- plugin_platform_interface...
|   '-- path_provider_windows 2.0.0
|       |-- ffi 1.0.0
|       |-- flutter...
|       |-- meta...
|       |-- path...
|       |-- path_provider_platform_interface...
|       '-- win32 2.0.3
|           '-- ffi...
|-- photo_view 0.11.1
|   '-- flutter...
|-- preload_page_view 0.1.5
|   '-- flutter...
|-- provider 5.0.0
|   |-- collection...
|   |-- flutter...
|   '-- nested 1.0.0
|       '-- flutter...
|-- shared_preferences 0.5.7+3
|   |-- flutter...
|   |-- meta...
|   |-- shared_preferences_macos 0.0.1+10
|   |   |-- flutter...
|   |   '-- shared_preferences_platform_interface...
|   |-- shared_preferences_platform_interface 1.0.4
|   |   |-- flutter...
|   |   '-- meta...
|   '-- shared_preferences_web 0.1.2+7
|       |-- flutter...
|       |-- flutter_web_plugins 0.0.0
|       |   |-- characters...
|       |   |-- collection...
|       |   |-- flutter...
|       |   |-- js...
|       |   |-- meta...
|       |   |-- typed_data...
|       |   '-- vector_math...
|       |-- meta...
|       '-- shared_preferences_platform_interface...
|-- timeago 3.0.2
'-- uuid 3.0.1
    '-- crypto 3.0.0
        |-- collection...
        '-- typed_data...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:12

github_iconTop GitHub Comments

3reactions
Rodrig0vcommented, Mar 21, 2021

This also happens randomly with Native ads on both iOS and android in nestedscrollviews, singlescrollviews and listviews. The ad will briefly flash on top of the list and then correct itself. Sometimes it might even stay at the top until the user decides to scroll.

2reactions
eliabiericommented, Mar 24, 2021

I have the same problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Banner Ads | iOS - Google Developers
Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen...
Read more >
Admob Banner at the top of the screen - Stack Overflow
I want to have the Admob banner at the top of the screen instead of the bottom. This is what i copied from...
Read more >
Create a banner ad unit - Google AdMob Help
Inline adaptive banners are intended to be placed inside scrollable content and can be much larger as the user will typically be able...
Read more >
Flutter AdMob Monetization – Banner and Interstitial Ads
Learn from the written tutorial & get the code 👇👇https://resocoder.com/ admob -flutter-tutorial📧 Get Flutter news 📰 and resources:👉 ...
Read more >
google_mobile_ads 0.13.4 | Flutter Package - Pub.dev
Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found