1+ import 'package:core/core.dart' ;
12import 'package:flutter/material.dart' ;
2- import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/banner_ad.dart' ; // Import BannerAd
3- import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/inline_ad.dart' ; // Import InlineAd
4- import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/native_ad.dart' ; // Import NativeAd
3+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/banner_ad.dart' ;
4+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/inline_ad.dart' ;
5+ import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/native_ad.dart' ;
56import 'package:google_mobile_ads/google_mobile_ads.dart' as admob;
67import 'package:logging/logging.dart' ;
78
@@ -20,11 +21,18 @@ import 'package:logging/logging.dart';
2021/// {@endtemplate}
2122class AdmobInlineAdWidget extends StatefulWidget {
2223 /// {@macro admob_inline_ad_widget}
23- const AdmobInlineAdWidget ({required this .inlineAd, super .key});
24+ const AdmobInlineAdWidget ({
25+ required this .inlineAd,
26+ this .headlineImageStyle,
27+ super .key,
28+ });
2429
2530 /// The generic inline ad model which contains the provider-specific AdMob ad object.
2631 final InlineAd inlineAd;
2732
33+ /// The user's preference for feed layout, used to determine the ad's visual size.
34+ final HeadlineImageStyle ? headlineImageStyle;
35+
2836 @override
2937 State <AdmobInlineAdWidget > createState () => _AdmobInlineAdWidgetState ();
3038}
@@ -90,7 +98,7 @@ class _AdmobInlineAdWidgetState extends State<AdmobInlineAdWidget> {
9098 return const SizedBox .shrink ();
9199 }
92100
93- // Determine the height based on the actual ad type.
101+ // Determine the height based on the actual ad type and headlineImageStyle .
94102 double adHeight;
95103 if (widget.inlineAd is NativeAd ) {
96104 final nativeAd = widget.inlineAd as NativeAd ;
@@ -99,8 +107,11 @@ class _AdmobInlineAdWidgetState extends State<AdmobInlineAdWidget> {
99107 NativeAdTemplateType .medium => 340 ,
100108 };
101109 } else if (widget.inlineAd is BannerAd ) {
102- // Standard banner ad height.
103- adHeight = 50 ; // AdSize.banner.height
110+ // For banner ads, adjust height based on headlineImageStyle.
111+ // If largeThumbnail, assume mediumRectangle (300x250), otherwise standard banner (320x50).
112+ adHeight = widget.headlineImageStyle == HeadlineImageStyle .largeThumbnail
113+ ? 250 // Height for mediumRectangle
114+ : 50 ; // Height for standard banner
104115 } else {
105116 // Fallback height for unknown inline ad types.
106117 adHeight = 100 ;
0 commit comments