bdlukaa / native_admob_flutter

Easy-to-make native ads in flutter using AdMOB SDK.
https://pub.dev/packages/native_admob_flutter
BSD 3-Clause "New" or "Revised" License
81 stars 57 forks source link

Plugin crashes on iOS 14.5 with Fatal error: Float value cannot be converted to Int #51

Closed jangruenwaldt closed 3 years ago

jangruenwaldt commented 3 years ago

Swift/x86_64-apple-ios-simulator.swiftinterface:32532: Fatal error: Float value cannot be converted to Int because it is either infinite or NaN

I call (initalize in main.dart, the getBannerAd() in the relevant widget)

MobileAds.initialize(bannerAdUnitId: MobileAds.bannerAdTestUnitId);

    Widget getBannerAd() => BannerAd(
          size: BannerSize.ADAPTIVE,
          error: Container(),
        );
jangruenwaldt commented 3 years ago

Nevermind, that cryptic error message comes from placing the BannerAd in a stack, can be fixed by:

Container(
                  width: MediaQuery.of(context).size.width,
                  child: BannerAdManager.instance.getBannerAd(),
                )

or any other width constraint. Thanks!