From 13c3ae6a6484e724ec1f74f261228e6ac5d34de5 Mon Sep 17 00:00:00 2001 From: Reko Paananen Date: Thu, 12 Dec 2024 14:18:38 +0200 Subject: [PATCH] enable custom gesture recognizers --- .../google_mobile_ads/lib/src/ad_containers.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/google_mobile_ads/lib/src/ad_containers.dart b/packages/google_mobile_ads/lib/src/ad_containers.dart index 83a038b7f..f55bd2723 100644 --- a/packages/google_mobile_ads/lib/src/ad_containers.dart +++ b/packages/google_mobile_ads/lib/src/ad_containers.dart @@ -651,11 +651,18 @@ class AdWidget extends StatefulWidget { /// Default constructor for [AdWidget]. /// /// [ad] must be loaded before this is added to the widget tree. - const AdWidget({Key? key, required this.ad}) : super(key: key); + const AdWidget({ + Key? key, + required this.ad, + this.gestureRecognizers, + }) : super(key: key); /// Ad to be displayed as a widget. final AdWithView ad; + /// Gesture recognizers to enable custom interactions with ads + final Set>? gestureRecognizers; + @override _AdWidgetState createState() => _AdWidgetState(); } @@ -714,7 +721,8 @@ class _AdWidgetState extends State { (BuildContext context, PlatformViewController controller) { return AndroidViewSurface( controller: controller as AndroidViewController, - gestureRecognizers: const >{}, + gestureRecognizers: widget.gestureRecognizers ?? + const >{}, hitTestBehavior: PlatformViewHitTestBehavior.opaque, ); }, @@ -736,6 +744,7 @@ class _AdWidgetState extends State { viewType: '${instanceManager.channel.name}/ad_widget', creationParams: instanceManager.adIdFor(widget.ad), creationParamsCodec: StandardMessageCodec(), + gestureRecognizers: widget.gestureRecognizers, ); } }