@@ -28,6 +28,7 @@ import 'dart:ui'
2828 StringAttribute,
2929 TextDirection,
3030 Tristate;
31+ import 'dart:ui' as ui show SemanticsHitTestBehavior;
3132
3233import 'package:collection/collection.dart' ;
3334import 'package:flutter/foundation.dart' ;
@@ -1020,6 +1021,7 @@ class SemanticsData with Diagnosticable {
10201021 required this .role,
10211022 required this .controlsNodes,
10221023 required this .validationResult,
1024+ required this .hitTestBehavior,
10231025 required this .inputType,
10241026 required this .locale,
10251027 this .tags,
@@ -1288,6 +1290,9 @@ class SemanticsData with Diagnosticable {
12881290 /// {@macro flutter.semantics.SemanticsProperties.validationResult}
12891291 final SemanticsValidationResult validationResult;
12901292
1293+ /// {@macro flutter.semantics.SemanticsProperties.hitTestBehavior}
1294+ final ui.SemanticsHitTestBehavior hitTestBehavior;
1295+
12911296 /// {@macro flutter.semantics.SemanticsNode.inputType}
12921297 final SemanticsInputType inputType;
12931298
@@ -1415,6 +1420,7 @@ class SemanticsData with Diagnosticable {
14151420 other.role == role &&
14161421 other.validationResult == validationResult &&
14171422 other.inputType == inputType &&
1423+ other.hitTestBehavior == hitTestBehavior &&
14181424 _sortedListsEqual (other.customSemanticsActionIds, customSemanticsActionIds) &&
14191425 setEquals <String >(controlsNodes, other.controlsNodes);
14201426 }
@@ -1451,8 +1457,7 @@ class SemanticsData with Diagnosticable {
14511457 validationResult,
14521458 controlsNodes == null ? null : Object .hashAll (controlsNodes! ),
14531459 inputType,
1454- traversalParentIdentifier,
1455- traversalChildIdentifier,
1460+ hitTestBehavior,
14561461 ),
14571462 );
14581463
@@ -1611,6 +1616,7 @@ class SemanticsProperties extends DiagnosticableTree {
16111616 this .controlsNodes,
16121617 this .inputType,
16131618 this .validationResult = SemanticsValidationResult .none,
1619+ this .hitTestBehavior,
16141620 this .onTap,
16151621 this .onLongPress,
16161622 this .onScrollLeft,
@@ -2555,6 +2561,13 @@ class SemanticsProperties extends DiagnosticableTree {
25552561 /// {@endtemplate}
25562562 final SemanticsValidationResult validationResult;
25572563
2564+ /// {@template flutter.semantics.SemanticsProperties.hitTestBehavior}
2565+ /// Describes how the semantic node should behave during hit testing.
2566+ ///
2567+ /// See [ui.SemanticsHitTestBehavior] for more details.
2568+ /// {@endtemplate}
2569+ final ui.SemanticsHitTestBehavior ? hitTestBehavior;
2570+
25582571 /// {@template flutter.semantics.SemanticsProperties.inputType}
25592572 /// The input type for of a editable widget.
25602573 ///
@@ -3235,7 +3248,8 @@ class SemanticsNode with DiagnosticableTreeMixin {
32353248 _headingLevel != config._headingLevel ||
32363249 _linkUrl != config._linkUrl ||
32373250 _role != config.role ||
3238- _validationResult != config.validationResult;
3251+ _validationResult != config.validationResult ||
3252+ _hitTestBehavior != config.hitTestBehavior;
32393253 }
32403254
32413255 // TAGS, LABELS, ACTIONS
@@ -3529,6 +3543,10 @@ class SemanticsNode with DiagnosticableTreeMixin {
35293543 SemanticsValidationResult get validationResult => _validationResult;
35303544 SemanticsValidationResult _validationResult = _kEmptyConfig.validationResult;
35313545
3546+ /// {@macro flutter.semantics.SemanticsProperties.hitTestBehavior}
3547+ ui.SemanticsHitTestBehavior get hitTestBehavior => _hitTestBehavior;
3548+ ui.SemanticsHitTestBehavior _hitTestBehavior = ui.SemanticsHitTestBehavior .defer;
3549+
35323550 /// {@template flutter.semantics.SemanticsNode.inputType}
35333551 /// The input type for of a editable node.
35343552 ///
@@ -3609,6 +3627,7 @@ class SemanticsNode with DiagnosticableTreeMixin {
36093627 _role = config._role;
36103628 _controlsNodes = config._controlsNodes;
36113629 _validationResult = config._validationResult;
3630+ _hitTestBehavior = config._hitTestBehavior;
36123631 _inputType = config._inputType;
36133632 _locale = config.locale;
36143633
@@ -3663,6 +3682,7 @@ class SemanticsNode with DiagnosticableTreeMixin {
36633682 SemanticsRole role = _role;
36643683 Set <String >? controlsNodes = _controlsNodes;
36653684 SemanticsValidationResult validationResult = _validationResult;
3685+ ui.SemanticsHitTestBehavior hitTestBehavior = _hitTestBehavior;
36663686 SemanticsInputType inputType = _inputType;
36673687 final Locale ? locale = _locale;
36683688 final Set <int > customSemanticsActionIds = < int > {};
@@ -3727,6 +3747,9 @@ class SemanticsNode with DiagnosticableTreeMixin {
37273747 if (inputType == SemanticsInputType .none) {
37283748 inputType = node._inputType;
37293749 }
3750+ if (hitTestBehavior == ui.SemanticsHitTestBehavior .defer) {
3751+ hitTestBehavior = node._hitTestBehavior;
3752+ }
37303753 if (tooltip == '' ) {
37313754 tooltip = node._tooltip;
37323755 }
@@ -3818,6 +3841,7 @@ class SemanticsNode with DiagnosticableTreeMixin {
38183841 role: role,
38193842 controlsNodes: controlsNodes,
38203843 validationResult: validationResult,
3844+ hitTestBehavior: hitTestBehavior,
38213845 inputType: inputType,
38223846 locale: locale,
38233847 );
@@ -3989,6 +4013,7 @@ class SemanticsNode with DiagnosticableTreeMixin {
39894013 role: data.role,
39904014 controlsNodes: data.controlsNodes? .toList (),
39914015 validationResult: data.validationResult,
4016+ hitTestBehavior: data.hitTestBehavior,
39924017 inputType: data.inputType,
39934018 locale: data.locale,
39944019 );
@@ -6415,6 +6440,14 @@ class SemanticsConfiguration {
64156440 _hasBeenAnnotated = true ;
64166441 }
64176442
6443+ /// {@macro flutter.semantics.SemanticsProperties.hitTestBehavior}
6444+ ui.SemanticsHitTestBehavior get hitTestBehavior => _hitTestBehavior;
6445+ ui.SemanticsHitTestBehavior _hitTestBehavior = ui.SemanticsHitTestBehavior .defer;
6446+ set hitTestBehavior (ui.SemanticsHitTestBehavior value) {
6447+ _hitTestBehavior = value;
6448+ _hasBeenAnnotated = true ;
6449+ }
6450+
64186451 /// {@macro flutter.semantics.SemanticsProperties.inputType}
64196452 SemanticsInputType get inputType => _inputType;
64206453 SemanticsInputType _inputType = SemanticsInputType .none;
@@ -6523,6 +6556,10 @@ class SemanticsConfiguration {
65236556 if (_hasExplicitRole && other._hasExplicitRole) {
65246557 return false ;
65256558 }
6559+ if (_hitTestBehavior != ui.SemanticsHitTestBehavior .defer ||
6560+ other._hitTestBehavior != ui.SemanticsHitTestBehavior .defer) {
6561+ return false ;
6562+ }
65266563 return true ;
65276564 }
65286565
@@ -6633,6 +6670,11 @@ class SemanticsConfiguration {
66336670 child._accessiblityFocusBlockType,
66346671 );
66356672
6673+ if (_hitTestBehavior == ui.SemanticsHitTestBehavior .defer &&
6674+ child._hitTestBehavior != ui.SemanticsHitTestBehavior .defer) {
6675+ _hitTestBehavior = child._hitTestBehavior;
6676+ }
6677+
66366678 _hasBeenAnnotated = hasBeenAnnotated || child.hasBeenAnnotated;
66376679 }
66386680
@@ -6678,7 +6720,8 @@ class SemanticsConfiguration {
66786720 .._role = _role
66796721 .._controlsNodes = _controlsNodes
66806722 .._validationResult = _validationResult
6681- .._inputType = _inputType;
6723+ .._inputType = _inputType
6724+ .._hitTestBehavior = _hitTestBehavior;
66826725 }
66836726}
66846727
0 commit comments