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

套件詳情v4.3.0

firebase_pagination

一個用於即時資料庫和 Firestore 分頁並支援即時更新的 Flutter 套件。

AndroidiOSWebmacOSWindows
近 30 天下載
2930
喜歡數
92
Pub 分數
160

安裝套件

flutter pub add firebase_pagination

套件介紹

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

Firebase Pagination 是一個 Flutter 套件,專為有效率地從 Firebase 實時資料庫和 Firestore 分頁資料而設計,支援即時更新。它簡化了逐步載入大量資料集的過程,確保順暢的效能與即時同步。此套件可無縫整合至 Flutter 的 ListView 及其他可捲動元件,自動處理分頁邏輯,例如載入狀態與清單結尾偵測。非常適合需要動態、回應式資料流的應用程式,如聊天介面、社群媒體動態或內容清單。

適用情境

  • 即時聊天應用
  • 社群媒體動態實作
  • 內容密集型儀表板
  • 動態清單加載與即時更新
  • 離線可用的資料擷取

主要特色

  • 來自 Firebase 的即時更新
  • 自動分頁處理
  • 支援即時資料庫與 Firestore
  • 內建的載入與錯誤狀態
  • 與 ListView 和 ScrollViews 的無縫整合

適合對象

  • 使用 Firebase 建構即時應用的開發者
  • 需要高效數據加載的應用程式
  • 需要離線支援與同步的項目
  • 使用 Flutter 和 Firebase 後端的團隊

使用建議

  • 需要 Firebase 設定和設定
  • 可能需要為大型數據集定制緩存策略
  • 僅限 Firebase 源
  • 性能取決於網路狀況和資料大小

原始 README

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

Firebase Pagination

A simple and effective way to Paginate Firebase related data.

pub package GitHub

GitHub issues open GitHub issues closed


Realtime Database Firestore
RealtimeDB Ascending Pagination Demo Firestore Pagination Demo
RealtimeDB Descending Pagination Demo

Features

  • FirestorePagination to simplify paginating firestore collections.
  • RealtimeDBPagination to simplify paginating realtime database nodes.
  • Get live updates when new data is added using isLive property.
  • Get realtime changes on already loaded data.
  • Descending pagination for RealtimeDBPagination.

Getting started

Add to Dependencies
firebase_pagination: ^4.2.0
Import the package
import 'package:firebase_pagination/firebase_pagination.dart';

Usage

Simplest Firestore Pagination
FirestorePagination(
  query: FirebaseFirestore.instance.collection('scores').orderBy('score'),
  itemBuilder: (context, docs, index) {
    final data = docs[index].data() as Map<String, dynamic>;

    // Do something cool with the data
  },
),
Simplest Firebase Realtime Database Pagination
RealtimeDBPagination(
  query: FirebaseDatabase.instance.ref().child('scores').orderByChild('score'),
  orderBy: 'score',
  itemBuilder: (context, dataNodes, index) {
    final data = dataNodes[index].value as Map<String, dynamic>;

    // Do something cool with the data
  },
),
For more examples, see the examples section.

How it Works

  • A data listener is added to the query with the given limit.
  • Every time the user scrolls to the bottom of the list, the limit is increased.
  • If there are any changes for the loaded data, it will be automatically updated.
  • If isLive is true, a live listener is added to fetch data before the first load. (i.e. Newly added data will be automatically loaded)
  • When new data is added, the data listener will be removed and a new data listener will be added with the new limit.
  • Also the live listener will be removed and a new live listener will be added.

Efficiency & Performance

  • Both FirestorePagination and RealtimeDBPagination uses maximum of two stream listeners to fetch data.
  • Hence it is performant and uses minimum amount of resources.
  • The listeners are automatically removed when the widget is removed from the widget tree.
  • For fetching data, the widgets uses this hack to minimize the number of reads from the database.

Description

Property Description Type Default
query The query to use to fetch data from Firestore / Realtime Database. Query -
itemBuilder The builder to use to build the items in the list. Function -
separatorBuilder The builder to use to render the separator. Function separatorBuilder (package fn)
limit The number of items to fetch from Database at once. int 10
viewType The type of view to use for the list. ViewType ViewType.list
isLive Whether to fetch newly added items as they are added to Database. bool false
gridDelegate The delegate to use for the GridView. SliverGridDelegate crossAxisCount: 2
wrapOptions The Wrap widget properties to use. WrapOptions WrapOptions()
pageOptions The PageView widget properties to use. PageOptions PageOptions()
onEmpty The widget to use when data is empty. Widget EmptyScreen()
bottomLoader The widget to use when more data is loading. Widget BottomLoader()
initialLoader The widget to use when data is loading initially. Widget InitialLoader()
scrollDirection The scrolling direction of the ScrollView. Axis false
reverse Whether the ScrollView scrolls in the reading direction. bool false
shrinkWrap Should the ScrollView be shrink-wrapped. bool false
physics The scroll behavior to use for the ScrollView. ScrollPhysics -
padding The padding to use for the ScrollView. EdgeInsetsGeometry -
controller The controller to use for the ScrollView. ScrollController ScrollController()
pageController The controller to use for the PageView. PageController PageController()
descending Whether the data should be fetched in descending order or not. Only works for RealtimeDBPagination bool false
If you liked the package, then please give it a Like 👍🏼 and Star ⭐

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。