搜尋套件、儲存庫與 APP 分類

fl_paging 封面
套件詳情v2.3.0

fl_paging

一個新的 Flutter 套件支援 ListView、GridView 與 NestedScrollView 的分頁

AndroidiOSmacOSWindowsLinux
近 30 天下載
323
喜歡數
27
Pub 分數
125

安裝套件

flutter pub add fl_paging

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

fl_paging 是一個 Flutter 套件,專為簡化 ListView、GridView 和 NestedScrollView 的分頁功能而設計。它提供一種乾淨、可重用的解決方案,可在使用者滾動時逐步載入資料,進而提升列表密集型應用的效能與使用者體驗。此套件支援 Android、iOS、macOS、Windows 及 Linux 多個平台,非常適合跨平台開發。僅需最少設定,開發者即可實作無限捲動,並內建狀態管理與錯誤處理。

適用情境

  • 無限滾動列表
  • 分頁網格顯示
  • 嵌套滾動視圖與懶加載
  • 資料密集型應用程式介面
  • 動態內容加載

主要特色

  • 支援 ListView、GridView 與 NestedScrollView
  • 內建的載入與錯誤狀態
  • 跨平台相容性
  • 與現有組件的簡單整合
  • 滾動時自動觸發分頁

適合對象

  • 開發基於清單應用程式的開發者
  • 需要高效資料載入的應用程式
  • 跨平台行動與桌面應用
  • 需要流暢滾動體驗的專案

使用建議

  • 需要自定義數據源實現
  • 可能需要額外的樣式以保持UI一致性
  • 未針對沒有快取的超大資料集進行優化
  • 僅限基於滾動的分頁

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Paging

Pub Package
Star on GitHub style: effective dart MIT License


A Flutter package that supports pagination(load infinite) for ListView, GridView

Demo
DataSource
PageKeyedDataSource

To create a PagingListView or PagingGridView you will need create class which extended from PageKeyedDataSource.

When extended from PageKeyedDataSource, you will need override 2 methods is loadInitial and loadPageAfter.

Output of those function is a Tuple2 with item1 is List is List of data, end item2 is next page index.

Example: if your list start with page index is 0. -> on loadInitial output is Tuple2([...], 1) 1 is next page when load more item.

Example:

class ListViewDataSource extends paging.PageKeyedDataSource<int, Note> {
  NoteRepository noteRepository;

  ListViewDataSource(this.noteRepository);

  @override
  Future<Tuple2<List<Note>, int>> loadInitial(int pageSize) async {
    return Tuple2(await noteRepository.getNotes(0), 1);
  }

  @override
  Future<Tuple2<List<Note>, int>> loadPageAfter(int params, int pageSize) async {
    return Tuple2(await noteRepository.getNotes(params), params + 1);
  }
}
Display on UI

To display on UI, currently you can use PagingListView or PagingGridView.

Example:

      ListViewDataSource dataSource = ListViewDataSource(NoteRepository());

      PagingListView<Note>(
        itemBuilder: (context, data, child) => NoteWidget(data),
        pageDataSource: dataSource,
      ),

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。