Repository navigation
The app crashes while trying to drag the Scrollbar when used along with SliverList #74404
Copy link
Copy link
Closed
Closed
Copy link
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Description
Steps to Reproduce
The app crashes while trying to drag the Scrollbar when used along with SliverList
const itemLength = 300;
Scrollbar(
controller: _scrollController,
child: CustomScrollView(
controller: _scrollController,
physics: const ScrollPhysics(),
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
if (index >= itemLength) {
return null;
}
return Container( width: 20);
}),
),
],
),
);Expected results:
Scroll should work fine when scrollbar is dragged using mouse pointer
Actual results:
Screen recordings:
- https://drive.google.com/file/d/14xabgQXPmU_MBA4APOIfrnGfwvBXfPlq/view?usp=sharing
- https://drive.google.com/file/d/1PAnfumdzqZt5L4wIfLCLRgpEXe8XzRd0/view?usp=sharing
- https://drive.google.com/file/d/1BOKPk3K47d5oogI7GYMNpB3lsjOfSrhM/view?usp=sharing
My observation:
- Scrolling using trackpad doesn't break the app
- Dragging and scrolling the scrollbar results in app crash.
- A couple of times I was able to pull the scrollbar out of the app window (of course the app crashed soon after).
- For a list with a lot of rows the scroll bar doesn't show up until we reach the bottom (the app crashes soon after dragging the scrollbar)
Error:
flutter: �[38;5;196m│ �[0m�[39m�[48;5;196m'package:flutter/src/rendering/viewport.dart': Failed assertion: line 1522 pos 12: 'correctedOffset.isFinite': is not true.�[0m�[49m
flutter: �[38;5;196m├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄�[0m
flutter: �[38;5;196m│ #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
flutter: �[38;5;196m│ #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
flutter: �[38;5;196m│ #2 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1522:12)
flutter: �[38;5;196m│ #3 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1479:20)
flutter: �[38;5;196m│ #4 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1634:7)
flutter: �[38;5;196m│ #5 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:884:18)
flutter: �[38;5;196m│ #6 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:453:19)
flutter: �[38;5;196m│ #7 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:870:13)
flutter: �[38;5;196m
Logs
[✓] Flutter (Channel master, 1.26.0-2.0.pre.419, on macOS 11.1 20C69
darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version
30.0.3)
[✓] Xcode - develop for iOS and macOS
flutter --version
Flutter 1.26.0-2.0.pre.419 • channel master • https://github.com/flutter/flutter.git
Framework • revision 913d5933c1 (89 minutes ago) • 2021-01-19 22:34:03 -0800
Engine • revision b58dbc88fc
Tools • Dart 2.12.0 (build 2.12.0-240.0.dev)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolef: scrollingViewports, list views, slivers, etc.Viewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Activity
LefebvreIlyas commentedon Jan 21, 2021
Hello @ganeshrvel the problem is probably in the following lines:
You must never return null for a widget!
Try this code please:
ganeshrvel commentedon Jan 21, 2021
But returning null is allowed for creating infinite list in
SliverList.itemLengthwon't be always available in such casesLefebvreIlyas commentedon Jan 21, 2021
Yes, you are right! 🤦♂️
From the doc of SliverChildBuilderDelegate.builder
LefebvreIlyas commentedon Jan 21, 2021
If it's an infinite list what should the scrollbar look like ?
HansMuller commentedon Jan 21, 2021
CC @Piinks
Piinks commentedon Jan 21, 2021
Scrollbar does not currently support infinite scroll views. You can follow #41434 for that feature.
Because of that, the Scrollbar should not show up if the scroll view has an infinite length, so I am curious why it is showing in your sample.
Piinks commentedon Jan 21, 2021
I think this is working as intended, since the Scrollbar is not intended to work this way currently. I was able to reproduce with this sample:
The reason why the
Scrollbardoes not show until you reach the bottom is because theSliverChildBuilderDelegatedoes not havechildCountset. So while you are scrolling down the list, themaxScrollExtentis infinity, therefore noScrollbaris painted.When you reach the end of the list and the delegate returns null, then the
maxScrollExtentis known and no longer infinite. That is why the Scrollbar shows up, it now has a length it can work with to calculate the right positioning, which is at the end of the list.When you try to drag on it at this point, scrolling back up the list, the
maxScrollExtentgoes to infinity again since we're no longer at the end of the list. This is what causes the crash, since you are now attempting to drag on a Scrollbar that is given infinite space to position itself in.I would recommend following #41434 for when we add support for infinitely scrollable scrollbars. If there is another aspect of this that is not covered by that issue, let us know and we will look into it. :) Thanks!
ganeshrvel commentedon Jan 21, 2021
@Piinks Wonderfully explained! I will close this issue for now. Thanks! :)
github-actions commentedon Aug 6, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.