@@ -312,6 +312,7 @@ class TapRegion extends SingleChildRenderObjectWidget {
312312 super .key,
313313 required super .child,
314314 this .enabled = true ,
315+ this .behavior = HitTestBehavior .deferToChild,
315316 this .onTapOutside,
316317 this .onTapInside,
317318 this .groupId,
@@ -321,6 +322,14 @@ class TapRegion extends SingleChildRenderObjectWidget {
321322 /// Whether or not this [TapRegion] is enabled as part of the composite region.
322323 final bool enabled;
323324
325+ /// How to behave during hit testing when deciding how the hit test propagates
326+ /// to children and whether to consider targets behind this [TapRegion] .
327+ ///
328+ /// Defaults to [HitTestBehavior.deferToChild] .
329+ ///
330+ /// See [HitTestBehavior] for the allowed values and their meanings.
331+ final HitTestBehavior behavior;
332+
324333 /// A callback to be invoked when a tap is detected outside of this
325334 /// [TapRegion] and any other region with the same [groupId] , if any.
326335 ///
@@ -358,6 +367,7 @@ class TapRegion extends SingleChildRenderObjectWidget {
358367 return RenderTapRegion (
359368 registry: TapRegionRegistry .maybeOf (context),
360369 enabled: enabled,
370+ behavior: behavior,
361371 onTapOutside: onTapOutside,
362372 onTapInside: onTapInside,
363373 groupId: groupId,
@@ -367,22 +377,25 @@ class TapRegion extends SingleChildRenderObjectWidget {
367377
368378 @override
369379 void updateRenderObject (BuildContext context, covariant RenderTapRegion renderObject) {
370- renderObject.registry = TapRegionRegistry .maybeOf (context);
371- renderObject.enabled = enabled;
372- renderObject.groupId = groupId;
373- renderObject.onTapOutside = onTapOutside;
374- renderObject.onTapInside = onTapInside;
375- if (kReleaseMode) {
380+ renderObject
381+ ..registry = TapRegionRegistry .maybeOf (context)
382+ ..enabled = enabled
383+ ..behavior = behavior
384+ ..groupId = groupId
385+ ..onTapOutside = onTapOutside
386+ ..onTapInside = onTapInside;
387+ if (! kReleaseMode) {
376388 renderObject.debugLabel = debugLabel;
377389 }
378390 }
379391
380392 @override
381393 void debugFillProperties (DiagnosticPropertiesBuilder properties) {
382394 super .debugFillProperties (properties);
395+ properties.add (FlagProperty ('enabled' , value: enabled, ifFalse: 'DISABLED' , defaultValue: true ));
396+ properties.add (DiagnosticsProperty <HitTestBehavior >('behavior' , behavior, defaultValue: HitTestBehavior .deferToChild));
383397 properties.add (DiagnosticsProperty <Object ?>('debugLabel' , debugLabel, defaultValue: null ));
384398 properties.add (DiagnosticsProperty <Object ?>('groupId' , groupId, defaultValue: null ));
385- properties.add (FlagProperty ('enabled' , value: enabled, ifFalse: 'DISABLED' , defaultValue: true ));
386399 }
387400}
388401
@@ -393,26 +406,33 @@ class TapRegion extends SingleChildRenderObjectWidget {
393406/// system.
394407///
395408/// This render object indicates to the nearest ancestor [TapRegionSurface] that
396- /// the region occupied by its child will participate in the tap detection for
397- /// that surface.
409+ /// the region occupied by its child (or itself if [behavior] is
410+ /// [HitTestBehavior.opaque] ) will participate in the tap detection for that
411+ /// surface.
398412///
399413/// If this region belongs to a group (by virtue of its [groupId] ), all the
400414/// regions in the group will act as one.
401415///
402416/// If there is no [RenderTapRegionSurface] ancestor in the render tree,
403417/// [RenderTapRegion] will do nothing.
404418///
419+ /// The [behavior] attribute describes how to behave during hit testing when
420+ /// deciding how the hit test propagates to children and whether to consider
421+ /// targets behind the tap region. Defaults to [HitTestBehavior.deferToChild] .
422+ /// See [HitTestBehavior] for the allowed values and their meanings.
423+ ///
405424/// See also:
406425///
407426/// * [TapRegion] , a widget that inserts a [RenderTapRegion] into the render
408427/// tree.
409- class RenderTapRegion extends RenderProxyBox {
428+ class RenderTapRegion extends RenderProxyBoxWithHitTestBehavior {
410429 /// Creates a [RenderTapRegion] .
411430 RenderTapRegion ({
412431 TapRegionRegistry ? registry,
413432 bool enabled = true ,
414433 this .onTapOutside,
415434 this .onTapInside,
435+ super .behavior = HitTestBehavior .deferToChild,
416436 Object ? groupId,
417437 String ? debugLabel,
418438 }) : _registry = registry,
0 commit comments