-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to Reproduce
Run this snippet:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: CustomScrollView(
physics: AlwaysScrollableScrollPhysics(),
slivers: [
SliverList(
delegate: SliverChildListDelegate(
[const SizedBox.shrink(), Text("item"), Text("item 2")]),
),
],
)),
);
}
}On the current master, dev or beta branch (the previous beta branch, 1.19.0-4.3.pre, works, but 1.20.0-7.2.pre crashes.)
Then fling the screen up a bit, the exception only happens when there is significant overscroll happening.
See https://streamable.com/i7eqce
Expected results:
I want the use case, that the first item of a SliverList is SizedBox.shrink(), be supported.
(Actually, my use case is more complex, I have a Widget that either renders something or returns SizedBox.shrink() if there is nothing to display. I don't want this logic to be in my SliverList, though).
Actual results:
On the latest Flutter versions, this is not supported, and an exception gets thrown:
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performLayout():
flutter: 'package:flutter/src/rendering/sliver.dart': Failed assertion: line 556 pos 15:
flutter: 'scrollOffsetCorrection != 0.0': is not true.
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter: https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: The relevant error-causing widget was:
flutter: SliverList file:///Users/kami/development/scroll_bug/lib/main.dart:17:11
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2 new SliverGeometry (package:flutter/src/rendering/sliver.dart:556:15)
flutter: #3 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:180:20)
flutter: #4 RenderObject.layout (package:flutter/src/rendering/object.dart:1776:7)
flutter: #5 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:471:13)
flutter: #6 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1466:12)
flutter: #7 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1375:20)
flutter: #8 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1639:7)
flutter: #9 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:896:18)
flutter: #10 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:404:19)
flutter: #11 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:881:13)
flutter: #12 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
flutter: #13 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1114:15)
flutter: #14 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1053:9)
flutter: #15 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:969:5)
flutter: #19 _invoke (dart:ui/hooks.dart:253:10)
flutter: #20 _drawFrame (dart:ui/hooks.dart:211:3)
flutter: (elided 5 frames from class _AssertionError and dart:async)
flutter:
flutter: The following RenderObject was being processed when the exception was fired: RenderSliverList#12304 relayoutBoundary=up1 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
flutter: needs compositing
flutter: creator: SliverList ← Viewport ← IgnorePointer-[GlobalKey#77b5f] ← Semantics ← _PointerListener ←
flutter: Listener ← _GestureSemantics ←
flutter: RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#6713c] ← _PointerListener ← Listener
flutter: ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#fde3c] ← ⋯
flutter: parentData: paintOffset=Offset(0.0, 0.0) (can use size)
flutter: constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.reverse,
flutter: scrollOffset: 240.4, remainingPaintExtent: 667.0, crossAxisExtent: 375.0, crossAxisDirection:
flutter: AxisDirection.right, viewportMainAxisExtent: 667.0, remainingCacheExtent: 1157.4, cacheOrigin:
flutter: -240.4)
flutter: geometry: SliverGeometry(scrollExtent: 17.0, hidden, maxPaintExtent: 17.0)
flutter: currently live children: 0 to 1
flutter: This RenderObject had the following descendants (showing up to depth 5):
flutter: child with index 0: RenderIndexedSemantics#78dd3 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: child: RenderRepaintBoundary#358a5 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
flutter: child: RenderConstrainedBox#6cefd relayoutBoundary=up4 NEEDS-PAINT
flutter: child with index 1: RenderIndexedSemantics#870ee relayoutBoundary=up2
flutter: child: RenderRepaintBoundary#1f7bf relayoutBoundary=up3
flutter: child: RenderParagraph#951c2 relayoutBoundary=up4
flutter: text: TextSpan
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: 'package:flutter/src/rendering/sliver.dart': Failed assertion: line 556 pos 15: 'scrollOffsetCorrection != 0.0': is not true.
flutter: Another exception was thrown: 'package:flutter/src/rendering/sliver.dart': Failed assertion: line 556 pos 15: 'scrollOffsetCorrection != 0.0': is not true.
flutter: Another exception was thrown: 'package:flutter/src/rendering/sliver.dart': Failed assertion: line 556 pos 15: 'scrollOffsetCorrection != 0.0': is not true.
flutter analyze
Analyzing scroll_bug...
No issues found! (ran in 2.9s)
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.21.0-6.0.pre.17, on Mac OS X 10.15.5 19F101, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.47.1)
[✓] Connected device (4 available)
! Doctor found issues in 1 category.