Comments (11)
Tarobins, when you make a paging scheme, like in a book, sending the initialScrollIndex always to position 0 the ScrollablePositionedList works perfectly. Now imagine a scenario where I do a words search in a book and by clicking on one of the results the ScrollablePositionedList will build and jump to a specific paragraph; So far so good, after that, I need to navigate to the previous or next chapter, I need to rebuild the state to bring in the new chapter by adding a new value to initialScrollIndex, in that case the initial index that corresponds to the first value of initialScrollIndex, it does not update. If of the itemCount is greater than this index value, not problem, because the range is larger, but if itemCount is smaller then the bug happens.
from flutter.widgets.
Even using JumpTo gives the same problem.
from flutter.widgets.
This issue has been resolved!
from flutter.widgets.
@oseiasmribeiro hi! How you resolve it?
from flutter.widgets.
How did you solve it? I am experiencing exactly the same issue.
Edit:
I solved it by keeping track of removed list items and returning widgets from the itemBuilder accordingly.
from flutter.widgets.
@AurelianTimu сould you give more information about your solution?
from flutter.widgets.
I simply upgraded to the latest version of the ScrollablePositionedList widget and it worked. Could you post some code examples showing the error? I can reopen the bug.
from flutter.widgets.
@iKrupp
See the comment I left in #77.
from flutter.widgets.
@oseiasmribeiro I got rangeError with this code:
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<int> array1;
List<int> array2;
List<int> array;
int initialIndex;
@override
void initState() {
super.initState();
array1 = List.generate(30, (index) => index);
array2 = List.generate(10, (index) => index);
array = array1;
initialIndex = 15;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: ScrollablePositionedList.builder(
initialScrollIndex: initialIndex,
itemBuilder: (context, index) => Container(
alignment: Alignment.bottomCenter,
padding: EdgeInsets.symmetric(vertical: 20),
child: Text('${array[index]}'),
),
itemCount: array.length,
)
),
Divider(),
OutlineButton(
child: Text('Load array2'),
onPressed: () {
setState(() {
array = array2;
initialIndex = 0;
});
},
),
],
),
),
);
}
}
from flutter.widgets.
I reopened the problem. Maybe the problem doesn't happen to me anymore because I wrapped the ScrollablePositionedList in a PageView. I will make my code available for you to analyze:
https://drive.google.com/file/d/1P88W7Mr2tA-RSeyJFiOU9Kv_Y_8Xt7oE/view?usp=sharing
from flutter.widgets.
@vabawen, I don't change the list dynamically as in your example. I use PageView for that! But I did a test with your code and for me the problem also occurs.
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.