Skip to content

Commit

Permalink
enable custom gesture recognizers
Browse files Browse the repository at this point in the history
  • Loading branch information
PaananenReko committed Jan 14, 2025
1 parent 406add0 commit 13c3ae6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/google_mobile_ads/lib/src/ad_containers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers;

@override
_AdWidgetState createState() => _AdWidgetState();
}
Expand Down Expand Up @@ -714,7 +721,8 @@ class _AdWidgetState extends State<AdWidget> {
(BuildContext context, PlatformViewController controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
gestureRecognizers: widget.gestureRecognizers ??
const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
Expand All @@ -736,6 +744,7 @@ class _AdWidgetState extends State<AdWidget> {
viewType: '${instanceManager.channel.name}/ad_widget',
creationParams: instanceManager.adIdFor(widget.ad),
creationParamsCodec: StandardMessageCodec(),
gestureRecognizers: widget.gestureRecognizers,
);
}
}
Expand Down

0 comments on commit 13c3ae6

Please sign in to comment.