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

パッケージ詳細v1.0.0

incrementally_loading_listview

スクロール時にデータを段階的に読み込むためのリストビュー小道具の拡張

30日間ダウンロード
218
いいね数
46
Pub ポイント
40

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

flutter pub add incrementally_loading_listview

パッケージ概要

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

スクロール中にインクリメンタルなデータ読み込みを可能にするようにListViewウィジェットを拡張するFlutterパッケージです。ユーザーがリストの終端に近づくと、自動的にデータ取得をトリガーし、パフォーマンスを過負荷にすることなく大規模なデータセットを処理するのに最適です。このパッケージは、スクロールイベントとロード状態をシームレスに管理することで、ページネーションロジックを簡素化します。カスタムローディングインジケーターとエラー処理をサポートしており、スムーズなユーザー体験を実現します。最小限のボイラープレートで効率的かつオフザシェルの遅延読み込みを求める開発者向けに設計されています。

用途

  • リアルタイムで大規模なデータセットを読み込む
  • 無限スクロールフィードの実装
  • ページネーションされたAPI結果を取得する
  • チャットやタイムラインインターフェースの構築
  • 長いリストでのパフォーマンス向上

主な機能

  • スクロール時の自動データ読み込み
  • カスタマイズ可能な読み込みインジケーター
  • 組み込みエラー処理
  • 既存の ListView との簡単な統合
  • 前方および逆方向のページネーションをサポート

適している対象

  • 動的なコンテンツフィードを構築する開発者
  • 広範なデータリストを備えたアプリ
  • スムーズなスクロールパフォーマンスを必要とするプロジェクト
  • ページネーションのボイラープレートを減らしたいチーム
  • ネットワークに依存するデータを備えたモバイルアプリ

注意事項

  • 適切な状態管理が必要です
  • 複雑な読み込みロジックに対応するためのカスタマイズが必要になる場合があります
  • 非常に高頻度の更新には最適化されていない
  • 制限されたプラットフォーム固有の最適化
  • 完全な機能を実現するには、外部の依存関係に依存しています

元の README

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

incrementally_loading_listview

pub package

An extension of the Flutter ListView widget for incrementally loading items upon scrolling. This could be used to load paginated data received from API requests.

NOTE: this package depends on rxdart. If you run into conflicts with different versions of rxdart, consider using dependency overrides as per this link

Getting Started

There's a working example that can be run to see how it works.

First import the library

import 'package:incrementally_loading_listview/incrementally_loading_listview.dart';

You can then use the IncrementallyLoadingListView widget in a similar way you would with the ListView.separated constructor

return IncrementallyLoadingListView(
    hasMore: () => _hasMoreItems,
    itemCount: () => items.length,
    loadMore: () async {
        // can shorten to "loadMore: _loadMoreItems" but this syntax is used to demonstrate that
        // functions with parameters can also be invoked if needed
        await _loadMoreItems();
    },
    loadMoreOffsetFromBottom: 2,
    itemBuilder: (context, index) {
        /// your builder function for rendering the item
    },
    separatorBuilder: (context, index) {
        /// your builder function for rendering the separator
    }
);

The widget allows passing in the same parameters you would to the ListView.builder constructor but itemCount is required so that when an item scrolls into view, it can see if it should attempt to load more items. Note that this is a callback that returns a boolean rather than being a boolean value. This allows the widget to not require a reference/copy of your data collection. The other parameters that can be specified are

  • hasMore: a callback that indicates if there are more items that can be loaded
  • loadMore: a callback to an asynchronous function that loads more items
  • loadMoreOffsetFromBottom: determines when the list view should attempt to load more items based on of the index of the item is scrolling into view. This is relative to the bottom of the list and has a default value of 0 so that it loads when the last item within the list view scrolls into view. As an example, setting this to 1 would attempt to load more items when the second last item within the list view scrolls into view
  • onLoadMore: a callback that is triggered when more items are being loaded. At first this will pass a boolean value of true to when items are being loaded by triggering the loadMore callback function. You could use this to update your UI to show a loading indicator
  • onLoadMoreFinished: a callback that is triggered when items have finished being loading. You can use this to hide your loading indicator
  • separatorBuilder: not required builder function that place separator between items

Providing onLoadMore and onLoadMoreFinished callbacks means the widget doesn't make assumptions on how you want to render a loading indicator so it will be up to your application to handle these callbacks to render the appropriate UI.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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

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