Comments (6)
I don't know if it is related to the following code
Timer.periodic(const Duration(milliseconds: 1000), (time) {
...............
dataList.add(item);
itemScrollController.jumpTo(
index: dataList.length - 1, alignment: 0.8);
}
});
from flutter.widgets.
Issue shows up if the content is too short to scroll to the desired location:
import 'package:flutter/material.dart';
import 'package:flutter_widgets/flutter_widgets.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
ItemScrollController itemScrollController = ItemScrollController();
void jumpEnd() {
itemScrollController.jumpTo(index: 1, alignment: 0.8);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ScrollablePositionedList.builder(
itemCount: 2,
itemBuilder: (context, index) => ConstrainedBox(
constraints: BoxConstraints.tightFor(height: 200),
child: Text(
'Item $index',
style: TextStyle(fontSize: 36),
),
),
itemScrollController: itemScrollController,
)),
floatingActionButton: FloatingActionButton(
onPressed: jumpEnd,
tooltip: 'Jump',
child: Icon(Icons.airline_seat_recline_normal),
),
);
}
}
Clicking on button results in
════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
'package:flutter/src/widgets/scroll_position.dart': Failed assertion: line 457 pos 14: 'minScrollExtent <= maxScrollExtent': is not true.
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=BUG.md
User-created ancestor of the error-causing widget was:
ScrollablePositionedList file:///Users/tarobins/scratch/min_max/lib/main.dart:42:43
When the exception was thrown, this was the stack:
#2 ScrollPosition.applyContentDimensions (package:flutter/src/widgets/scroll_position.dart:457:14)
#3 UnboundedRenderViewport.performLayout (package:flutter_widgets/src/scrollable_positioned_list/src/viewport.dart:140:20)
#4 RenderObject.layout (package:flutter/src/rendering/object.dart:1716:7)
#5 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:105:13)
#6 RenderObject.layout (package:flutter/src/rendering/object.dart:1716:7)
...
The following RenderObject was being processed when the exception was fired: UnboundedRenderViewport#4e0b8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: <none> (can use size)
... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=603.4)
... layer: OffsetLayer#6d6d5
... offset: Offset(0.0, 0.0)
... size: Size(411.4, 603.4)
... axisDirection: down
... crossAxisDirection: right
... offset: ScrollPositionWithSingleContext#ce2dd(offset: 0.0, range: 0.0..0.0, viewport: 603.4, ScrollableState, ClampingScrollPhysics, IdleScrollActivity#02106, ScrollDirection.idle)
... anchor: 0.8
RenderObject: UnboundedRenderViewport#4e0b8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
needs compositing
parentData: <none> (can use size)
constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=603.4)
layer: OffsetLayer#6d6d5
offset: Offset(0.0, 0.0)
size: Size(411.4, 603.4)
axisDirection: down
crossAxisDirection: right
offset: ScrollPositionWithSingleContext#ce2dd(offset: 0.0, range: 0.0..0.0, viewport: 603.4, ScrollableState, ClampingScrollPhysics, IdleScrollActivity#02106, ScrollDirection.idle)
anchor: 0.8
... child -1: RenderSliverPadding#ec516 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: paintOffset=Offset(0.0, 282.7) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.reverse, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 482.7, crossAxisExtent: 411.4, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 603.4, remainingCacheExtent: 1689.6 cacheOrigin: 0.0 )
... geometry: SliverGeometry(scrollExtent: 200.0, paintExtent: 200.0, maxPaintExtent: 200.0, cacheExtent: 200.0)
... scrollExtent: 200.0
... paintExtent: 200.0
... maxPaintExtent: 200.0
... cacheExtent: 200.0
... padding: EdgeInsets.zero
... textDirection: ltr
... child: RenderSliverList#b7836 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: paintOffset=Offset(0.0, 0.0) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.reverse, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 482.7, crossAxisExtent: 411.4, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 603.4, remainingCacheExtent: 1689.6 cacheOrigin: 0.0 )
... geometry: SliverGeometry(scrollExtent: 200.0, paintExtent: 200.0, maxPaintExtent: 200.0, cacheExtent: 200.0)
... scrollExtent: 200.0
... paintExtent: 200.0
... maxPaintExtent: 200.0
... cacheExtent: 200.0
... currently live children: 0 to 0
... child with index 0: RenderRepaintBoundary#fbb7e relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: index=0; layoutOffset=0.0 (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=Infinity)
... layer: OffsetLayer#53138
... offset: Offset(0.0, 282.7)
... size: Size(411.4, 200.0)
... metrics: 0.0% useful (1 bad vs 0 good)
... diagnosis: insufficient data to draw conclusion (less than five repaints)
... child: RenderIndexedSemantics#65d31 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=Infinity)
... semantic boundary
... size: Size(411.4, 200.0)
... index: 0
... center child: RenderSliverPadding#c91fc relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: paintOffset=Offset(0.0, 482.7) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 120.7, crossAxisExtent: 411.4, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 603.4, remainingCacheExtent: 1327.5 cacheOrigin: 0.0 )
... geometry: SliverGeometry(scrollExtent: 200.0, paintExtent: 120.7, maxPaintExtent: 200.0, hasVisualOverflow: true, cacheExtent: 200.0)
... scrollExtent: 200.0
... paintExtent: 120.7
... maxPaintExtent: 200.0
... hasVisualOverflow: true
... cacheExtent: 200.0
... padding: EdgeInsets.zero
... textDirection: ltr
... child: RenderSliverList#0a718 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: paintOffset=Offset(0.0, 0.0) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 120.7, crossAxisExtent: 411.4, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 603.4, remainingCacheExtent: 1327.5 cacheOrigin: 0.0 )
... geometry: SliverGeometry(scrollExtent: 200.0, paintExtent: 120.7, maxPaintExtent: 200.0, hasVisualOverflow: true, cacheExtent: 200.0)
... scrollExtent: 200.0
... paintExtent: 120.7
... maxPaintExtent: 200.0
... hasVisualOverflow: true
... cacheExtent: 200.0
... currently live children: 0 to 0
... child with index 0: RenderRepaintBoundary#1e8f7 relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... needs compositing
... parentData: index=0; layoutOffset=0.0 (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=Infinity)
... layer: OffsetLayer#eacbb
... offset: Offset(0.0, 482.7)
... size: Size(411.4, 200.0)
... metrics: 0.0% useful (1 bad vs 0 good)
... diagnosis: insufficient data to draw conclusion (less than five repaints)
... child: RenderIndexedSemantics#c3c35 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: <none> (can use size)
... constraints: BoxConstraints(w=411.4, 0.0<=h<=Infinity)
... semantic boundary
... size: Size(411.4, 200.0)
... index: 1
... child 1: RenderSliverPadding#1b8af relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: paintOffset=Offset(0.0, 682.7) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 0.0, crossAxisExtent: 411.4, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 603.4, remainingCacheExtent: 1127.5 cacheOrigin: 0.0 )
... geometry: SliverGeometry(scrollExtent: 0.0, hidden, maxPaintExtent: 0.0)
... scrollExtent: 0.0
... hidden
... maxPaintExtent: 0.0
... padding: EdgeInsets.zero
... textDirection: ltr
... child: RenderSliverList#57043 relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData: paintOffset=Offset(0.0, 0.0) (can use size)
... constraints: SliverConstraints(AxisDirection.down, GrowthDirection.forward, ScrollDirection.idle, scrollOffset: 0.0, remainingPaintExtent: 0.0, crossAxisExtent: 411.4, crossAxisDirection: AxisDirection.right, viewportMainAxisExtent: 603.4, remainingCacheExtent: 1127.5 cacheOrigin: 0.0 )
... geometry: SliverGeometry(scrollExtent: 0.0, hidden, maxPaintExtent: 0.0)
... scrollExtent: 0.0
... hidden
... maxPaintExtent: 0.0
... no children current live
════════════════════════════════════════════════════════════════════════════════════════════════════
from flutter.widgets.
I should probably make the list bounce using whatever physics are set when the user scrolls too far.
from flutter.widgets.
@tarobins I'm also getting this a lot. I believe solving this issue should get some priority, since you can't really know if it the content is too short or not. So there's no work around for this one.
However, bouncing back (animating) is not the correct behavior. As I said, when you jump to some item you can't really know if it the content is too short or not, so you will get what seems to be "random" bounces. It's even worse if, say, you're jumping from top to bottom, but you overshoot and then it bounces from bottom to top, which is very disorienting since the user will think it somehow moved to the opposite direction.
What it should do, instead, is just jump instantly to the resting position (the position it would settle if a bouncing back would occur).
from flutter.widgets.
I've written a doc that proposes a solution to this bug and a few other. If you are interested in the solution to this bug, please take a look and leave comments.
https://docs.google.com/document/d/1ozIndwAbYcd96ktOX8LnsZ1L-K08q2XvdDD3G_ruEE8/edit#
from flutter.widgets.
@tarobins Added my comments there already.
from flutter.widgets.
Related Issues (20)
- VisibilityDetector fires event unexpectedly HOT 1
- [ScrollablePositionedList] Scrollbar unexpected jumping HOT 2
- [scrollable_positioned_list]: add jumpTo method to ScrollOffsetController
- [ScrollablePositionedList] PageStorage cast bug
- [ScrollablePositionedList] with StickyHeader
- Unsupported operation: add
- Twitchy scroll animation
- Inconsistent Expansion Direction of AnimatedContainer in ScrollablePositionedList
- [visibility_detector] Incorrect Visibility info Bug after updating to 4.0.0 or later
- A RenderViewport exceeded its maximum number of layout cycles
- R
- RTL support scrollable_positioned_list HOT 1
- Allow or expose scroll controller to be used outside.
- [visibility_detector] onVisibilityChanged not works when scroll faster HOT 5
- Flutter_simple_treeview: could not configure tree node height
- flutter simple tree: lazy build subtree nodes
- [ScrollablePositionedList] Inactive Package
- [visibility_detector] iOS swipe back - Unexpected visibleFraction behaviour. It is just 1.0 or 0.0.
- Use webview load pie charts on ios platform will show blank page in first load, and changed reloadAfterInit to true have blow error.
- Is the scrollable positioned list still in maintenance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter.widgets.