diff --git a/packages/flutter/lib/src/rendering/sliver_persistent_header.dart b/packages/flutter/lib/src/rendering/sliver_persistent_header.dart index 29fdc01f08..b88c7d66ca 100644 --- a/packages/flutter/lib/src/rendering/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/rendering/sliver_persistent_header.dart @@ -258,27 +258,10 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje } } - /// Whether the [SemanticsNode]s associated with this [RenderSliver] should - /// be excluded from the semantic scrolling area. - /// - /// [RenderSliver]s that stay on the screen even though the user has scrolled - /// past them (e.g. a pinned app bar) should set this to true. - @protected - bool get excludeFromSemanticsScrolling => _excludeFromSemanticsScrolling; - bool _excludeFromSemanticsScrolling = false; - set excludeFromSemanticsScrolling(bool value) { - if (_excludeFromSemanticsScrolling == value) - return; - _excludeFromSemanticsScrolling = value; - markNeedsSemanticsUpdate(); - } - @override void describeSemanticsConfiguration(SemanticsConfiguration config) { super.describeSemanticsConfiguration(config); - - if (_excludeFromSemanticsScrolling) - config.addTagForChildren(RenderViewport.excludeFromScrolling); + config.addTagForChildren(RenderViewport.excludeFromScrolling); } @override @@ -375,7 +358,6 @@ abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistent final SliverConstraints constraints = this.constraints; final double maxExtent = this.maxExtent; final bool overlapsContent = constraints.overlap > 0.0; - excludeFromSemanticsScrolling = overlapsContent || (constraints.scrollOffset > maxExtent - minExtent); layoutChild(constraints.scrollOffset, maxExtent, overlapsContent: overlapsContent); final double effectiveRemainingPaintExtent = math.max(0, constraints.remainingPaintExtent - constraints.overlap); final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, effectiveRemainingPaintExtent) as double; @@ -575,7 +557,6 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste } else { _effectiveScrollOffset = constraints.scrollOffset; } - excludeFromSemanticsScrolling = _effectiveScrollOffset <= constraints.scrollOffset; final bool overlapsContent = _effectiveScrollOffset < constraints.scrollOffset; layoutChild( diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 4d1e9be7e4..3ea6249e45 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -1647,22 +1647,20 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], children: [ TestSemantics( - children: [ - TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, - ), - ], + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, ), ], ), + TestSemantics( + flags: [SemanticsFlag.hasImplicitScrolling], + ), ], ), ], diff --git a/packages/flutter/test/widgets/sliver_semantics_test.dart b/packages/flutter/test/widgets/sliver_semantics_test.dart index 53f03b822e..285b282079 100644 --- a/packages/flutter/test/widgets/sliver_semantics_test.dart +++ b/packages/flutter/test/widgets/sliver_semantics_test.dart @@ -79,6 +79,20 @@ void _tests() { TestSemantics( id: 2, children: [ + TestSemantics( + id: 7, + children: [ + TestSemantics( + id: 8, + flags: [ + SemanticsFlag.namesRoute, + SemanticsFlag.isHeader, + ], + label: 'Semantics Test with Slivers', + textDirection: TextDirection.ltr, + ), + ], + ), TestSemantics( id: 9, flags: [ @@ -86,20 +100,6 @@ void _tests() { ], actions: [SemanticsAction.scrollUp], children: [ - TestSemantics( - id: 7, - children: [ - TestSemantics( - id: 8, - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.isHeader, - ], - label: 'Semantics Test with Slivers', - textDirection: TextDirection.ltr, - ), - ], - ), TestSemantics( id: 3, label: 'Item 0', @@ -226,6 +226,20 @@ void _tests() { TestSemantics( id: 2, children: [ + TestSemantics( + id: 7, + children: [ + TestSemantics( + id: 8, + flags: [ + SemanticsFlag.namesRoute, + SemanticsFlag.isHeader, + ], + label: 'Semantics Test with Slivers', + textDirection: TextDirection.ltr, + ), + ], + ), TestSemantics( id: 9, flags: [ @@ -236,20 +250,6 @@ void _tests() { SemanticsAction.scrollDown, ], children: [ - TestSemantics( - id: 7, - children: [ - TestSemantics( - id: 8, - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.isHeader, - ], - label: 'Semantics Test with Slivers', - textDirection: TextDirection.ltr, - ), - ], - ), TestSemantics( id: 3, label: 'Item 0',