Closed desmeit closed 2 months ago
if you know offset, you can create a controller with the needed initial position ScrollController. initialScrollOffset
. Just keep in mind that on first run Flutter will build list items starting from 0 position up to provided offset and then will dispose items that aren't visible.
Another option split your collection into 2 - one for items in the past (neg list) from your selected date, and one for current date and everything that goes in future (pos list). In that way, Current date will become the center of you list (e.g starting point for scrollable area)
Okay I understand. If I try option 2, how can I work with negative indexes since Dart is not working with negative indexes?
Everything depends on that collection you actually have. If you have Lists for both pos and neg collections, then you need to convert negative index in the builder to the positive number that corresponds to the index in negative list.
If you using Maps were key is a Date object, you can do selectedDate.add(Duration (days: index))
and you will get your Date key
At the first start I want to show a specific item of my InfiniteList. How is that possible?