Repository navigation
Open
Labels
P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility team
Description
Steps to reproduce
flutter create bug- Replace
bug/test/widget_test.dartwith the code sample below. cd bugandflutter test
The ClipRect test passes; the other tests fail.
Expected results
The semantics rect of a child is clipped by the clip its parent applies in paint, as it is under ClipRect:
flutter/packages/flutter/lib/src/rendering/object.dart
Lines 3755 to 3768 in ab29120
| /// Returns a rect in this object's coordinate system that describes | |
| /// the approximate bounding box of the clip rect that would be | |
| /// applied to the given child during the paint phase, if any. | |
| /// | |
| /// Returns null if the child would not be clipped. | |
| /// | |
| /// This is used in the semantics phase to avoid including children | |
| /// that are not physically visible. | |
| /// | |
| /// RenderObjects that respect a [Clip] behavior when painting _must_ respect | |
| /// that same behavior when describing this value. For example, if passing | |
| /// [Clip.none] to [PaintingContext.pushClipRect] as the `clipBehavior`, then | |
| /// the implementation of this method must return null. | |
| Rect? describeApproximatePaintClip(covariant RenderObject child) => null; |
Actual results
The following render objects clip their children in paint but don't override describeApproximatePaintClip, so the semantics rect of a clipped child is not clipped. Results on Flutter 3.50.0, where only the top half of a 100x100 child is inside the clip:
| Widget | Render object | Expected semantics rect | Actual semantics rect | Result |
|---|---|---|---|---|
ClipRect (reference) |
RenderClipRect |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 50) |
Correct |
Wrap |
RenderWrap |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 100) |
Wrong. The second run overflows the Wrap and is clipped, but its semantics rect is not. |
FittedBox |
RenderFittedBox |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 100) |
Wrong. The child is taller than the FittedBox and is clipped, but its semantics rect is not. |
Flow |
RenderFlow |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 100) |
Wrong. The delegate paints the child 50 down, where it is clipped, but its semantics rect is not. |
Text.rich |
RenderParagraph |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 100) |
Wrong. The second line overflows the text and is clipped, but its semantics rect is not. |
TwoDimensionalViewport |
RenderTwoDimensionalViewport |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 100) |
Wrong. The second child overflows the viewport and is clipped, but its semantics rect is not. |
AnimatedSize |
RenderAnimatedSize |
Rect.fromLTRB(0, 0, 100, 50) |
Rect.fromLTRB(0, 0, 100, 100) |
Wrong. The AnimatedSize is 50 high while growing and clips the child, but its semantics rect is not clipped. |
Related: #103748 and #103931 fixed the opposite case, render objects that described a clip they did not apply.
Code sample
Code sample
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
final cases = <String, Widget>{
'ClipRect (reference)': const ClipRect(
child: OverflowBox(
alignment: .topLeft,
maxHeight: double.infinity,
child: Column(children: [SizedBox(height: 50), _Target()]),
),
),
'Wrap': const Wrap(
clipBehavior: .hardEdge,
children: [SizedBox(width: 100, height: 50), _Target()],
),
'FittedBox': const FittedBox(
fit: .none,
alignment: .topLeft,
clipBehavior: .hardEdge,
child: Column(children: [SizedBox(height: 50), _Target()]),
),
'Flow': Flow(
delegate: _OffsetFlow(),
clipBehavior: .hardEdge,
children: const [_Target()],
),
'Text.rich': const Text.rich(
TextSpan(
children: [
WidgetSpan(child: SizedBox(width: 100, height: 50)),
WidgetSpan(child: _Target()),
],
),
overflow: .clip,
),
'TwoDimensionalViewport': _Grid(
children: const [SizedBox(width: 100, height: 50), _Target()],
),
'AnimatedSize': const _Growing(),
};
for (final MapEntry(:key, :value) in cases.entries) {
testWidgets('$key clips the semantics rect of a half clipped child', (
tester,
) async {
final handle = tester.ensureSemantics();
await tester.pumpWidget(
Directionality(
textDirection: .ltr,
child: Align(
alignment: .topLeft,
child: SizedBox(width: 100, height: 100, child: value),
),
),
);
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
tester.getSemantics(find.bySemanticsLabel('target')).rect.height,
50,
reason: 'Only the top half of the target is inside the clip.',
);
handle.dispose();
});
}
}
class _Target extends StatelessWidget {
const _Target();
@override
Widget build(BuildContext context) {
return Semantics(
label: 'target',
container: true,
child: const SizedBox(width: 100, height: 100),
);
}
}
class _OffsetFlow extends FlowDelegate {
@override
void paintChildren(FlowPaintingContext context) {
context.paintChild(0, transform: .translationValues(0, 50, 0));
}
@override
bool shouldRepaint(_OffsetFlow oldDelegate) => false;
}
// Minimal implementation of RenderTwoDimensionalViewport for this test,
// laying out the children in a column.
class _Grid extends TwoDimensionalScrollView {
_Grid({required List<Widget> children})
: super(delegate: TwoDimensionalChildListDelegate(children: [children]));
@override
Widget buildViewport(
BuildContext context,
ViewportOffset verticalOffset,
ViewportOffset horizontalOffset,
) {
return _GridViewport(
verticalOffset: verticalOffset,
verticalAxisDirection: verticalDetails.direction,
horizontalOffset: horizontalOffset,
horizontalAxisDirection: horizontalDetails.direction,
mainAxis: mainAxis,
delegate: delegate,
);
}
}
class _GridViewport extends TwoDimensionalViewport {
const _GridViewport({
required super.verticalOffset,
required super.verticalAxisDirection,
required super.horizontalOffset,
required super.horizontalAxisDirection,
required super.mainAxis,
required super.delegate,
});
@override
RenderTwoDimensionalViewport createRenderObject(BuildContext context) {
return _RenderGrid(
verticalOffset: verticalOffset,
verticalAxisDirection: verticalAxisDirection,
horizontalOffset: horizontalOffset,
horizontalAxisDirection: horizontalAxisDirection,
mainAxis: mainAxis,
delegate: delegate,
childManager: context as TwoDimensionalChildManager,
);
}
}
class _RenderGrid extends RenderTwoDimensionalViewport {
_RenderGrid({
required super.verticalOffset,
required super.verticalAxisDirection,
required super.horizontalOffset,
required super.horizontalAxisDirection,
required super.mainAxis,
required super.delegate,
required super.childManager,
});
@override
void layoutChildSequence() {
var top = 0.0;
for (var x = 0; ; x++) {
final child = buildOrObtainChildFor(ChildVicinity(xIndex: x, yIndex: 0));
if (child == null) {
break;
}
child.layout(const BoxConstraints(), parentUsesSize: true);
parentDataOf(child).layoutOffset = Offset(0, top);
top += child.size.height;
}
verticalOffset.applyContentDimensions(0, 0);
horizontalOffset.applyContentDimensions(0, 0);
}
}
// Grows an AnimatedSize from 0 to 100 high, so that it is 50 high after 500ms.
class _Growing extends StatefulWidget {
const _Growing();
@override
State<_Growing> createState() => _GrowingState();
}
class _GrowingState extends State<_Growing> {
var _grown = false;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback(
(_) => setState(() => _grown = true),
);
}
@override
Widget build(BuildContext context) {
return Align(
alignment: .topLeft,
child: AnimatedSize(
duration: const Duration(seconds: 1),
alignment: .topLeft,
child: _grown ? const _Target() : const SizedBox(width: 100),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
Captured with shutter. The blue border is the 100x100 clip, and the semantics images draw the semantics tree.
| Widget | Screenshot | Semantics |
|---|---|---|
ClipRect (reference) |
![]() |
![]() |
Wrap |
![]() |
![]() |
FittedBox |
![]() |
![]() |
Flow |
![]() |
![]() |
Text.rich |
![]() |
![]() |
TwoDimensionalViewport |
![]() |
![]() |
AnimatedSize |
![]() |
![]() |
Logs
Logs
$ flutter test
00:00 +1: Wrap clips the semantics rect of a half clipped child
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <50>
Actual: <100.0>
Only the top half of the target is inside the clip.
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart:60:7)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1968:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart line 60
The test description was:
Wrap clips the semantics rect of a half clipped child
════════════════════════════════════════════════════════════════════════════════════════════════════
00:00 +1 -1: Wrap clips the semantics rect of a half clipped child [E]
Test failed. See exception logs above.
The test description was: Wrap clips the semantics rect of a half clipped child
To run this test again: /Users/koji/flutter/bin/cache/dart-sdk/bin/dart test /Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart -p vm --plain-name 'Wrap clips the semantics rect of a half clipped child'
00:00 +1 -1: FittedBox clips the semantics rect of a half clipped child
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <50>
Actual: <100.0>
Only the top half of the target is inside the clip.
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart:60:7)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1968:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart line 60
The test description was:
FittedBox clips the semantics rect of a half clipped child
════════════════════════════════════════════════════════════════════════════════════════════════════
00:00 +1 -2: FittedBox clips the semantics rect of a half clipped child [E]
Test failed. See exception logs above.
The test description was: FittedBox clips the semantics rect of a half clipped child
To run this test again: /Users/koji/flutter/bin/cache/dart-sdk/bin/dart test /Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart -p vm --plain-name 'FittedBox clips the semantics rect of a half clipped child'
00:00 +1 -2: Flow clips the semantics rect of a half clipped child
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <50>
Actual: <100.0>
Only the top half of the target is inside the clip.
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart:60:7)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1968:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart line 60
The test description was:
Flow clips the semantics rect of a half clipped child
════════════════════════════════════════════════════════════════════════════════════════════════════
00:00 +1 -3: Flow clips the semantics rect of a half clipped child [E]
Test failed. See exception logs above.
The test description was: Flow clips the semantics rect of a half clipped child
To run this test again: /Users/koji/flutter/bin/cache/dart-sdk/bin/dart test /Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart -p vm --plain-name 'Flow clips the semantics rect of a half clipped child'
00:00 +1 -3: Text.rich clips the semantics rect of a half clipped child
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <50>
Actual: <100.0>
Only the top half of the target is inside the clip.
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart:60:7)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1968:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart line 60
The test description was:
Text.rich clips the semantics rect of a half clipped child
════════════════════════════════════════════════════════════════════════════════════════════════════
00:00 +1 -4: Text.rich clips the semantics rect of a half clipped child [E]
Test failed. See exception logs above.
The test description was: Text.rich clips the semantics rect of a half clipped child
To run this test again: /Users/koji/flutter/bin/cache/dart-sdk/bin/dart test /Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart -p vm --plain-name 'Text.rich clips the semantics rect of a half clipped child'
00:00 +1 -4: TwoDimensionalViewport clips the semantics rect of a half clipped child
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <50>
Actual: <100.0>
Only the top half of the target is inside the clip.
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart:60:7)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1968:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart line 60
The test description was:
TwoDimensionalViewport clips the semantics rect of a half clipped child
════════════════════════════════════════════════════════════════════════════════════════════════════
00:00 +1 -5: TwoDimensionalViewport clips the semantics rect of a half clipped child [E]
Test failed. See exception logs above.
The test description was: TwoDimensionalViewport clips the semantics rect of a half clipped child
To run this test again: /Users/koji/flutter/bin/cache/dart-sdk/bin/dart test /Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart -p vm --plain-name 'TwoDimensionalViewport clips the semantics rect of a half clipped child'
00:00 +1 -5: AnimatedSize clips the semantics rect of a half clipped child
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: <50>
Actual: <100.0>
Only the top half of the target is inside the clip.
When the exception was thrown, this was the stack:
#4 main.<anonymous closure> (file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart:60:7)
<asynchronous suspension>
#5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1968:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
This was caught by the test expectation on the following line:
file:///Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart line 60
The test description was:
AnimatedSize clips the semantics rect of a half clipped child
════════════════════════════════════════════════════════════════════════════════════════════════════
00:00 +1 -6: AnimatedSize clips the semantics rect of a half clipped child [E]
Test failed. See exception logs above.
The test description was: AnimatedSize clips the semantics rect of a half clipped child
To run this test again: /Users/koji/flutter/bin/cache/dart-sdk/bin/dart test /Users/koji/workspace/packages/frame_visibility/issues/describe_approximate_paint_clip/test/widget_test.dart -p vm --plain-name 'AnimatedSize clips the semantics rect of a half clipped child'
00:00 +1 -6: Some tests failed.Flutter Doctor output
Doctor output
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.50.0, on macOS 27.2.1 26B131 darwin-arm64, locale ja-JP) [309ms]
• Flutter version 3.50.0 on channel stable at /Users/koji/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ab2912035e (6 days ago), 2026-11-09 08:50:21 -0800
• Engine revision 371f77202a
• Dart version 3.14.0
• DevTools version 2.61.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use,
enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,518ms]
• Android SDK at /Users/koji/Library/Android/sdk
• Emulator version 37.2.13.0 (build_id 16740729) (CL:N/A)
• Platform android-37.0, build-tools 36.0.0
• ANDROID_HOME = /Users/koji/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 25.0.4+-16339643-b508.27)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 27.2) [912ms]
• Xcode at /Applications/Xcode-27.2.0.app/Contents/Developer
• Build 27B52
• CocoaPods version 1.17.0
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (2 available) [6.7s]
• macOS (desktop) • macos • darwin-arm64 • macOS 27.2.1 26B131 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 157.0.8103.51
[✓] Network resources [309ms]
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility team














Activity
saurabh-mirajkar commentedon Nov 16, 2026
@koji-1009 Thanks for the report.
I reproduced the issue on Flutter 3.50.0 stable.
ClipRectpasses, while the other six test cases fail.Labeled and routed to the accessibility team for further investigation.
Related issue: #103951