RenderTreeSliver.paint does not subtract constraints.scrollOffset from animating clip rect
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in packages/flutter/lib/src/rendering/sliver_tree.dart, where the issue identifies the clip rectangle in RenderTreeSliver.paint and compares it with paintUpTo positioning. Check how the scroll offset is applied to paint coordinates, then reproduce by scrolling to Parent 19 and toggling it. Done when its children animate smoothly beneath the parent while scrolled, matching the behavior at offset zero.
Written by the indexing model from the issue text.
Description
Steps to reproduce
- Run the code sample below (
flutter run). - Scroll to the bottom of the list so
Parent 19is visible (scrollOffset > 0). - Tap
Parent 19to expand or collapse it (the 500ms animation duration makes the clipping easy to observe).
Expected results
Parent 19's children smoothly slide out from directly underneath Parent 19, matching the animation when expanding Parent 0 at scrollOffset == 0.
Actual results
The clip rectangle pushed by RenderTreeSliver.paint (packages/flutter/lib/src/rendering/sliver_tree.dart, lines 379–387) is computed from layout offsets without subtracting constraints.scrollOffset:
final double leadingOffset =
indexToLayoutOffset(0.0, parentIndex) + itemExtentBuilder(parentIndex, layoutDimensions)!;
final double trailingOffset =
indexToLayoutOffset(0.0, segment.trailingIndex) +
itemExtentBuilder(segment.trailingIndex, layoutDimensions)!;
final rect = Rect.fromPoints(
Offset(0.0, leadingOffset),
Offset(constraints.crossAxisExtent, trailingOffset),
);
By contrast, paintUpTo in the same method (line 331) positions children in paint coordinates with parentData.layoutOffset! - constraints.scrollOffset. Because the clip rect is not shifted by -constraints.scrollOffset, it is offset downwards by scrollOffset whenever the sliver is scrolled. As a result, expanding/collapsing children near the bottom of a scrolled TreeSliver are clipped out during the animation and abruptly pop in or out once the animation finishes and the clip layer is removed.
(Note: PR #194172 also noted this bug in its review follow-up as out of scope for that PR.)
Code sample
Code sample
import 'package:material_ui/material_ui.dart';
void main() => runApp(const MaterialApp(home: TreeSliverClipBug()));
class TreeSliverClipBug extends StatefulWidget {
const TreeSliverClipBug({super.key});
@override
State<TreeSliverClipBug> createState() => _TreeSliverClipBugState();
}
class _TreeSliverClipBugState extends State<TreeSliverClipBug> {
final List<TreeSliverNode<String>> _tree = [
for (int i = 0; i < 20; i++)
TreeSliverNode<String>(
'Parent $i',
children: [
for (int j = 0; j < 4; j++) TreeSliverNode<String>('Child $i.$j'),
],
),
TreeSliverNode<String>('Padding'),
TreeSliverNode<String>('Padding'),
TreeSliverNode<String>('Padding'),
TreeSliverNode<String>('Padding'),
TreeSliverNode<String>('Padding'),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('TreeSliver scrollOffset clip bug')),
body: CustomScrollView(
slivers: [
TreeSliver<String>(
tree: _tree,
toggleAnimationStyle: const AnimationStyle(
duration: Duration(milliseconds: 500),
),
),
],
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
(No dedicated video capture software on this work machine, Windows Snip tool too low framerate)
Logs
Logs
No errors or exceptions are thrown.
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.50.0, on Microsoft Windows [Version 10.0.26200.9911], locale en-BE) [3.2s]
• Flutter version 3.50.0 on channel stable at C:\Users\<user>\Flutter\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ab2912035e (3 weeks 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
[√] Windows Version (Windows 11 or higher, 25H2, 2009) [8.0s]
[X] Android toolchain - develop for Android devices [1,316ms]
X Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/to/windows-android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[√] Chrome - develop for the web [1,273ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2026 18.6.2) [1,272ms]
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools
• Visual Studio Build Tools 2026 version 18.6.11822.322
• Windows 10 SDK version 10.0.26100.0
[√] Connected device (3 available) [1,340ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26200.9911]
• Chrome (web) • chrome • web-javascript • Google Chrome 158.0.8127.88
• Edge (web) • edge • web-javascript • Microsoft Edge 149.0.4022.69
[√] Network resources [422ms]
• All expected network resources are available.
! Doctor found issues in 1 category.
- Dominant language
- Dart
- Stars
- 182k
- Forks
- 32k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 336
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from flutter/flutter
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
flutter/flutter#197796 · 1 comment ·
Maintainers usually reply within 1 day
-
[integration_test] Failure details are lost in profile and release builds ("Instance of 'FlutterErrorDetails'" or empty)Possibly taken @danielleon-cmd claimed this today. Opena: release a: tests f: integration_test framework has reproducible steps team-framework
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
flutter/flutter#197770 · 1 assignee ·
Maintainers usually reply within 1 day
-
p: material_ui P3 package team-design triaged-design
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
[TabBarView] has no scrollDirection (PageView already supports it)Possibly taken @joellemd claimed this 1 day ago. Opena: tests framework has reproducible steps p: material_ui P3 package team-design triaged-design
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
flutter/flutter#197669 · 1 comment ·
Maintainers usually reply within 1 day
-
CupertinoNavigationBar: enableBackgroundFilterBlur: false is ignored during the route transition (hero flight)Possibly taken @danielleon-cmd claimed this 2 days ago. Openfound in release: 3.47 has reproducible steps p: cupertino_ui P2 package team-design triaged-design
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
flutter/flutter#197590 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
lang-java needs-triage package:jni package:jni_flutter package:jnigen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
finamp-app/finamp#1920 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
package:skills
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day