パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v4.0.0

indexed_list_view

インデックスによって、プログラム的に任意のアイテムに即座にジャンプできる無限ListView。あらゆるサイズのリストに対応し、パフォーマンスが優れています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1510
いいね数
233
Pub ポイント
150

パッケージをインストール

flutter pub add indexed_list_view

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

インデックスで任意のアイテムに即座にプログラム制御スクロールが可能なパフォーマンス重視の無限ListViewです。高速なナビゲーションが必要な大規模データセットに最適です。表示されている項目のみを効率的にレンダリングし、すべてのプラットフォームで滑らかなパフォーマンスを維持します。既存のFlutterアプリとのシームレスな統合をサポートしており、動的なコンテンツに最適化されています。スピードやメモリ使用量を犠牲にせずに応答性のあるリスト操作を実現したい開発者向けに設計されています。

用途

  • 即時インデックスベースのナビゲーションを備えた大規模なデータリスト
  • リアルタイムでの動的コンテンツの更新
  • モバイルおよびWebアプリにおける高パフォーマンススクロール
  • 無限リストの効率的なレンダリング
  • データ集約型インターフェースにおけるスムーズなユーザー体験

主な機能

  • インデックスでリストの任意の項目に即座にジャンプ
  • 大規模データセットの最適化レンダリング
  • 最小限のメモリオーバーヘッドで無限スクロールをサポート
  • クロスプラットフォーム互換性
  • 組み込みのパフォーマンス最適化
  • 既存のFlutterプロジェクトとの簡単な統合

適している対象

  • データ集約型アプリを開発する開発者
  • 高速リストナビゲーションを必要とするアプリ
  • 複数のプラットフォームをターゲットにするチーム
  • 大規模または動的に更新されるリストを含むプロジェクト
  • 応答性のあるUIインタラクションを必要とするユーザー

注意事項

  • アイテムインデックスの慎重な管理が必要です
  • 複雑なアイテムレイアウトには追加の論理が必要になる場合があります
  • 静的で小さなリストには適していない
  • パフォーマンスはアイテムの複雑さに依存します
  • 頻繁なインデックスジャンプが発生するシナリオに最適

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

pub package

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:

IndexedListView.builder(
    controller: controller, 
    itemBuilder: itemBuilder);

There is also the separated constructor, same as ListView.separated:

IndexedListView.separated(
    controller: controller, 
    itemBuilder: itemBuilder,
    separatorBuilder: separatorBuilder);

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

  1. 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.

  2. jumpToIndexAndOffset(index, offset)

    Jumps the origin-index to the given index, and the scroll-position to offset, without animation.

  3. 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.

  4. animateToIndexAndOffset(index, offset)

    Same as animateToIndex() but also lets you specify the new offset.

  5. jumpTo(offset)

    Goes to origin-index "0", and then jumps the scroll position from its current value to the given offset, without animation.

  6. 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.

  7. jumpToWithSameOriginIndex(offset)

    Jumps the offset, relative to the current origin-index.

  8. animateToWithSameOriginIndex(offset)

    Animates the offset, relative to the current origin-index.

  9. jumpToRelative(offset)

    Jumps the offset, adding or subtracting from the current offset. It keeps the same origin-index.

  10. 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.


This package got some ideas from Collin Jackson's code in StackOverflow, and uses lots of code from Simon Lightfoot's infinite_listview.

By Marcelo Glasberg

glasberg.dev
github.com/marcglasberg
linkedin.com/in/marcglasberg/
twitter.com/glasbergmarcelo
stackoverflow.com/users/3411681/marcg
medium.com/@marcglasberg

My article in the official Flutter documentation:

The Flutter packages I've authored:

My Medium Articles:

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。