인덱스를 통해 어떤 항목이든 즉시 프로그래밍 방식으로 스크롤할 수 있는 성능이 뛰어난 무한 ListView입니다. 빠른 탐색이 필수적인 대규모 데이터셋에 적합합니다. 보이는 항목만 효율적으로 렌더링하여 모든 플랫폼에서 부드러운 성능을 유지합니다. 기존의 Flutter 앱과 원활하게 통합되며 동적 콘텐츠에 최적화되어 있습니다. 속도나 메모리 사용량을 희생하지 않고 반응성 있는 리스트 상호작용을 원하는 개발자를 위한 설계입니다.
사용 사례
즉시 인덱스 기반 탐색이 가능한 대규모 데이터 목록
실시간 동적 콘텐츠 업데이트
모바일 및 웹 앱에서 고성능 스크롤링
무한 목록의 효율적인 렌더링
데이터 집약적 인터페이스에서의 부드러운 사용자 경험
주요 기능
인덱스를 통해 목록의 어떤 항목으로도 즉시 이동
대규모 데이터셋을 위한 최적화 렌더링
최소한의 메모리 오버헤드로 무한 스크롤을 지원
크로스 플랫폼 호환성
내장된 성능 최적화
기존 Flutter 프로젝트와의 간편한 통합
적합한 대상
데이터 집약형 앱을 개발하는 개발자
빠른 리스트 탐색이 필요한 앱
다양한 플랫폼을 대상으로 하는 팀
큰 또는 동적으로 업데이트되는 목록을 포함하는 프로젝트
반응형 UI 상호작용이 필요한 사용자
고려 사항
항목 인덱스의 신중한 관리가 필요합니다
복잡한 항목 레이아웃을 위해 추가 로직이 필요할 수 있습니다
정적이고 작은 목록에는 적합하지 않음
성능은 항목의 복잡성에 따라 달라집니다
자주 인덱스가 점프하는 시나리오에 가장 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
indexed_list_view
Similar to a ListView, but:
Lets you programmatically jump to any item, by index.
The jump happens instantly, no matter if you have millions of items.
It can also animate the scroll, instead of jumping.
Limitations
The list is always infinite both to positive and negative indexes.
In other words, it can be scrolled indefinitely both to the top and to the bottom.
In special, this is useful for implementing calendars, where you want to be able to
jump to specific dates, as calendars can be scrolled indefinitely, both to the past and
future dates.
You can define index bounds by giving it a minItemCount and maxItemCount, but this
will not prevent the list from scrolling indefinitely. When showing items out of the index
bounds, or when your itemBuilder returns null, it will ask the emptyItemBuilder to
create an "empty" item to be displayed instead. As default, this will return empty
containers.
Usage
First, create an indexed scroll controller:
var controller = IndexedScrollController();
Optionally, you may setup an initial index and/or initial scroll offset:
var controller = IndexedScrollController(
initialIndex: 75,
initialScrollOffset : 30.0);
Then, create the indexed list view, and pass it the controller:
To jump, use the controller methods like jumpToIndex :
controller.jumpToIndex(10000);
Details
The IndexedScrollController has not only an offset in pixels, but also an origin-index
that indicates which item is considered to be at the offset position 0.0.
So there are two ways for you to move the list programmatically:
You can change only the offset, or else change the originIndex and the offset at the
same time.
To change the originIndex you make an "index jump". This jump is cheap, since it doesn't
need to build all widgets between the old and new positions. It will just change the
origin.
If you want to move the list programmatically you must create a scroll controller of
type IndexedScrollController and pass it in the list constructor. However, if all you
need is an infinite list without jumps, then there is no need to even create a controller.
You move the list programmatically by calling the controller methods.
Controller Methods
jumpToIndex(index)
This is the most common method for you to use. It jumps the origin-index to the given
index, and the scroll-position to 0.0.
jumpToIndexAndOffset(index, offset)
Jumps the origin-index to the given index, and the scroll-position to offset, without
animation.
animateToIndex(index)
If the current origin-index is already the same as the given index, animates the
position from its current value to the offset position relative to the origin-index.
However, if the current origin-index is different from the given index, this will jump
to the new index, without any animation. In general, there are never animations when
the index changes.
animateToIndexAndOffset(index, offset)
Same as animateToIndex() but also lets you specify the new offset.
jumpTo(offset)
Goes to origin-index "0", and then jumps the scroll position from its current value to
the given offset, without animation.
animateTo(offset)
If the current origin-index is already "0", animates the position from its current
value to the offset position.
However, if the current origin-index is different from "0", this will jump to index "0"
and the given offset, without any animation. In general, there are never animations
when the index changes.
jumpToWithSameOriginIndex(offset)
Jumps the offset, relative to the current origin-index.
animateToWithSameOriginIndex(offset)
Animates the offset, relative to the current origin-index.
jumpToRelative(offset)
Jumps the offset, adding or subtracting from the current offset. It keeps the same
origin-index.
animateToRelative(offset)
Animates the offset, adding or subtracting from the current offset. It keeps the same
origin-index.
Don't forget to check
the example tab. It
shows an infinite list of items of different heights, and you may tap buttons to run some
of the methods explained above.