Describe the issue:
When user overscrolls, a layout exception is thrown
โโโก EXCEPTION CAUGHT BY RENDERING LIBRARY โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The following assertion was thrown during performLayout():
SliverGeometry is not valid: The "scrollExtent" is negative.
The RenderSliver that returned the offending geometry was: _RenderSliverOverlapAbsorberX#c28e4 relayoutBoundary=up1 NEEDS-PAINT:
needs compositing
creator: CustomSliverOverlapAbsorber โ _ProfileSliverAppBar โ BlocListener<AuthWatcherCubit,
AuthWatcherState> โ BlocSelector<AuthWatcherCubit, AuthWatcherState, User?> โ
_NestedScrollViewViewport โ IgnorePointer-[GlobalKey#eb7c8] โ Semantics โ Listener โ
_GestureSemantics โ RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#e565b] โ
Listener โ _ScrollableScope โ โฏ
parentData: paintOffset=Offset(0.0, 0.0) (can use size)
constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.forward,
scrollOffset: 0.0, remainingPaintExtent: 748.0, overlap: -148.0, crossAxisExtent: 414.0,
crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 896.0, remainingCacheExtent:
998.0, cacheOrigin: 0.0)
geometry: SliverGeometry(scrollExtent: -0.0, paintExtent: 296.0, paintOrigin: -148.0, layoutExtent:
148.0, maxPaintExtent: 296.0, hasVisualOverflow: true, cacheExtent: 148.0)
handle: _SliverOverlapAbsorberHandle(0.0null)
The relevant error-causing widget was:
CustomSliverOverlapAbsorber
CustomSliverOverlapAbsorber:file:///Users/brendan/Mobile/FlutterProjects/sorosoke/lib/features/dashboard/presentation/screens/profile_sc
reen.dart:125:12
When the exception was thrown, this was the stack:
#0 SliverGeometry.debugAssertIsValid.<anonymous closure>.verify (package:flutter/src/rendering/sliver.dart:712:9)
#1 SliverGeometry.debugAssertIsValid.<anonymous closure> (package:flutter/src/rendering/sliver.dart:721:7)
#2 SliverGeometry.debugAssertIsValid (package:flutter/src/rendering/sliver.dart:751:6)
#3 RenderSliver.debugAssertDoesMeetConstraints (package:flutter/src/rendering/sliver.dart:1205:22)
#4 RenderObject.layout.<anonymous closure> (package:flutter/src/rendering/object.dart:2138:9)
#5 RenderObject.layout (package:flutter/src/rendering/object.dart:2140:8)
#6 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:516:13)
#7 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1600:12)
#8 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1507:20)
#9 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1973:7)
#10 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:999:18)
#11 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:513:19)
#12 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:884:13)
#13 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:378:5)
#14 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1175:15)
#15 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1104:9)
#16 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1015:5)
#20 _invoke (dart:ui/hooks.dart:150:10)
#21 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)
#22 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
The following RenderObject was being processed when the exception was fired: _RenderSliverOverlapAbsorberX#c28e4 relayoutBoundary=up1
NEEDS-PAINT:
needs compositing
creator: CustomSliverOverlapAbsorber โ _ProfileSliverAppBar โ BlocListener<AuthWatcherCubit,
AuthWatcherState> โ BlocSelector<AuthWatcherCubit, AuthWatcherState, User?> โ
_NestedScrollViewViewport โ IgnorePointer-[GlobalKey#eb7c8] โ Semantics โ Listener โ
_GestureSemantics โ RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#e565b] โ
Listener โ _ScrollableScope โ โฏ
parentData: paintOffset=Offset(0.0, 0.0) (can use size)
constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.forward,
scrollOffset: 0.0, remainingPaintExtent: 746.7, overlap: -149.3, crossAxisExtent: 414.0,
crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 896.0, remainingCacheExtent:
996.7, cacheOrigin: 0.0)
geometry: SliverGeometry(scrollExtent: -1.3, paintExtent: 297.3, paintOrigin: -149.3, layoutExtent:
148.0, maxPaintExtent: 297.3, hasVisualOverflow: true, cacheExtent: 148.0)
handle: _SliverOverlapAbsorberHandle(0.0null)
This RenderObject had the following descendants (showing up to depth 5):
child: _RenderSliverPinnedPersistentHeaderForWidgets#10042 relayoutBoundary=up2 NEEDS-PAINT
child: RenderSemanticsAnnotations#f31e0 relayoutBoundary=up3 NEEDS-PAINT
child: RenderAnnotatedRegion<SystemUiOverlayStyle>#434e1 relayoutBoundary=up4 NEEDS-PAINT
child: RenderPhysicalModel#bf5d5 relayoutBoundary=up5 NEEDS-PAINT
child: _RenderInkFeatures#eba97 relayoutBoundary=up6 NEEDS-PAINT
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Another exception was thrown: SliverGeometry is not valid: The "scrollExtent" is negative.
Steps to Reproduce:
Use the default example in the Readme.md
- Change
minHeight
to 100
- Change
maxHeight
to 120
- Pull down the
ScrollView
past 120 (maxHeight)
- Platform - iOS
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: DefaultTabController(
length: 2,
child: CustomNestedScrollView(
overscrollType: CustomOverscroll.outer,
// !important
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics(),
),
headerSliverBuilder: (context, innerScrolled) => <Widget>[
MySliverAppBar(),
],
body: TabBarView(
children: [
CustomScrollView(
// !important
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics(),
),
slivers: <Widget>[
TopOverlapInjector(),
// scroll view
SliverFixedExtentList(
delegate: SliverChildBuilderDelegate(
(_, index) => ListTile(
key: Key('$index'),
title: Center(
child: Text('ListTile ${index + 1}'),
),
),
childCount: 30,
),
itemExtent: 50,
),
],
),
CustomScrollView(
physics: NeverScrollableScrollPhysics(),
slivers: <Widget>[
TopOverlapInjector(),
// some widget
SliverFillRemaining(
child: Center(
child: Text('Test'),
),
),
],
),
],
),
),
),
);
}
}
class TopOverlapInjector extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Builder(
builder: (context) => CustomSliverOverlapInjector(
overscrollType: CustomOverscroll.outer,
handle: CustomNestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
);
}
}
class MySliverAppBar extends StatelessWidget {
///Header collapsed height
final minHeight = 100.0;
///Header expanded height
final maxHeight = 120.0;
final tabBar = TabBar(
tabs: <Widget>[Text('Tab1'), Text('Tab2')],
);
@override
Widget build(BuildContext context) {
final topHeight = MediaQuery.of(context).padding.top;
return CustomSliverOverlapAbsorber(
overscrollType: CustomOverscroll.outer,
handle: CustomNestedScrollView.sliverOverlapAbsorberHandleFor(
context,
),
sliver: SliverAppBar(
pinned: true,
stretch: true,
toolbarHeight: minHeight - tabBar.preferredSize.height - topHeight,
collapsedHeight: minHeight - tabBar.preferredSize.height - topHeight,
expandedHeight: maxHeight - topHeight,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Center(child: Text('Example')),
stretchModes: <StretchMode>[
StretchMode.zoomBackground,
StretchMode.blurBackground,
],
background: Image.network(
'https://pic1.zhimg.com/80/v2-fc35089cfe6c50f97324c98f963930c9_720w.jpg',
fit: BoxFit.cover,
),
),
bottom: tabBar,
),
);
}
}