We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As shown in the image admob banner ad is cut off or stretched.
If I use AdSize.banner widget does not take the entire width but shows the ad correctly. If I use full-banner the ad is stretched.
How do I get the banner to fit the full width of the screen and show the content correctly (without cut off or streached)?
class _AdBannerState extends State<AdBanner> { BannerAd? _inlineAdaptiveAd; bool _isLoaded = false; AdSize? _finalSize; @override void didChangeDependencies() { super.didChangeDependencies(); _loadAd(); } void _loadAd() async { await _inlineAdaptiveAd?.dispose(); setState(() { _inlineAdaptiveAd = null; _isLoaded = false; }); // Get an inline adaptive size for the current orientation. AdSize size = AdSize.fullBanner; _inlineAdaptiveAd = BannerAd( adUnitId: AdHelper.bannerAdUnitId, size: size, request: const AdRequest(), listener: BannerAdListener( onAdLoaded: (Ad ad) async { debugPrint('Inline adaptive banner loaded: ${ad.responseInfo}'); // After the ad is loaded, get the platform ad size and use it to // update the height of the container. This is necessary because the // height can change after the ad is loaded. BannerAd bannerAd = (ad as BannerAd); _finalSize = await bannerAd.getPlatformAdSize(); // if (size == null) { // debugPrint( // 'Error: getPlatformAdSize() returned null for $bannerAd'); // return; // } setState(() { _inlineAdaptiveAd = bannerAd; _isLoaded = true; }); }, onAdFailedToLoad: (Ad ad, LoadAdError error) { debugPrint('Inline adaptive banner failedToLoad: $error'); ad.dispose(); }, ), ); await _inlineAdaptiveAd!.load(); } @override Widget build(BuildContext context) { return (_inlineAdaptiveAd != null && _isLoaded && _finalSize != null) ? Expanded( child: SizedBox( width: _finalSize!.width.toDouble(), height: _finalSize!.height.toDouble(), child: AdWidget( ad: _inlineAdaptiveAd!, ))) : const SizedBox( width: 0, height: 0, ); } @override void dispose() { _inlineAdaptiveAd?.dispose(); super.dispose(); } }
Flutter 3.10.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 84a1e904f4 (3 weeks ago) • 2023-05-09 07:41:44 -0700 Engine • revision d44b5a94c9 Tools • Dart 3.0.0 • DevTools 2.23.1
The text was updated successfully, but these errors were encountered:
Thanks for the report! This is a known issue being tracked at #261. And you may wanna take a look at #261 (comment) for the workaround.
Closing this issue as a duplicate, so please follow up on it for further updates.
Sorry, something went wrong.
No branches or pull requests
As shown in the image admob banner ad is cut off or stretched.
If I use AdSize.banner widget does not take the entire width but shows the ad correctly. If I use full-banner the ad is stretched.
How do I get the banner to fit the full width of the screen and show the content correctly (without cut off or streached)?
Flutter 3.10.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 84a1e904f4 (3 weeks ago) • 2023-05-09 07:41:44 -0700 Engine • revision d44b5a94c9 Tools • Dart 3.0.0 • DevTools 2.23.1
The text was updated successfully, but these errors were encountered: