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

套件詳情v1.32.8

firestore_ui

firebase_database 的 FirebaseAnimatedList 移植版本,適用於 cloud_firestore,並帶有額外變體

AndroidiOSWebmacOSWindows
近 30 天下載
222
喜歡數
75
Pub 分數
140

安裝套件

flutter pub add firestore_ui

套件介紹

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

firestore_ui 是一個 Flutter 套件,將 FirebaseAnimatedList 的功能帶到 Cloud Firestore,支援從 Firestore 集合中動態、動畫地呈現清單。它支援即時更新,並包含適用於不同使用情境的其他變體,例如分頁或過濾清單。專為與 Firebase 的雲端資料庫無縫整合而設計,可簡化建立回應式 UI 的過程,讓跨平台的即時資料變更得以呈現。

適用情境

  • 即時資料列表顯示
  • 來自 Firestore 的動態內容更新
  • 分頁或篩選的 Firestore 列表
  • 即時協作應用
  • 離線可用的列表檢視

主要特色

  • 動畫列表渲染
  • 支援即時 Firestore 更新
  • 包含多種清單變體
  • 跨平台相容性
  • 類似於 FirebaseAnimatedList 的簡單 API

適合對象

  • 使用 Cloud Firestore 的開發者
  • 需要即時更新清單的應用程式
  • UI密集型Firebase應用
  • Flutter 項目在多個平台

使用建議

  • 需要 Firebase 和 Cloud Firestore 設定
  • 可能影響大資料集的效能
  • 與原始 ListView 相比,自訂選項有限
  • 最適合中等規模的收藏
  • 取決於 Firebase SDK 版本相容性

原始 README

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

firestore_ui

pub package

This project started as a Pull Request to the official cloud_firestore plugin, but unfortunately they are still polishing the main features and this had to be postponed; it's based on firebase_database's version.

But fear not, my fellow Cloud Firestore users, this is a package that extracted the main code from that PR and now it's available to use!

Custom parameters

  • bool linear - This will make it so it just uses .add instead of .insert, this usually leads to less issues in the order if your list updates linearly (like a chat)
  • void onLoaded(QuerySnapshot snapshot) - You can use this to access the most recent QuerySnapshot that came from the stream
  • bool filter(DocumentSnapshot snapshot) - This allows you to filter out specific snapshots on the rendering phase, return true if you want that item to be filtered
  • bool debug - Set this to see all logs related to inserting/removing/updating items on any variant of the list

How to use

All the examples below are from the actual example folder, please run that to see how it behaves!

List

Just set it up as you would with a ListView.builder:

FirestoreAnimatedList(
    query: query,
    itemBuilder: (
        BuildContext context,
        DocumentSnapshot snapshot,
        Animation<double> animation,
        int index,
    ) => FadeTransition(
        opacity: animation,
        child: MessageListTile(
            index: index,
            document: snapshot,
            onTap: _removeMessage,
        ),
    ),
);

Grid

Just set it up as you would with a GridView.count, alongside the necessary crossAxisCount, all the other parameters from the SliverGridDelegateWithFixedCrossAxisCount are also available:

FirestoreAnimatedGrid(
    query: query,
    crossAxisCount: 2,
    mainAxisSpacing: 4.0,
    childAspectRatio: 1.0,
    crossAxisSpacing: 4.0,
    itemBuilder: (
        BuildContext context,
        DocumentSnapshot snapshot,
        Animation<double> animation,
        int index,
    ) => FadeTransition(
        opacity: animation,
        child: MessageGridTile(
            index: index,
            document: snapshot,
            onTap: _removeMessage,
        ),
    ),
);

Staggered

Just set it up as you would with a StaggeredGridView.countBuilder, alongside the necessary crossAxisCount and the staggeredTileBuilder:

FirestoreAnimatedStaggered(
    query: query,
    staggeredTileBuilder: (int index, DocumentSnapshot snapshot) => StaggeredTile.count(2, index.isEven ? 2 : 1),
    crossAxisCount: 4,
    mainAxisSpacing: 4.0,
    crossAxisSpacing: 4.0,
    itemBuilder: (
        BuildContext context,
        DocumentSnapshot snapshot,
        Animation<double> animation,
        int index,
    ) => FadeTransition(
        opacity: animation,
        child: MessageGridTile(
            index: index,
            document: snapshot,
            onTap: _removeMessage,
        ),
    ),
);

Special thanks to @letsar for the flutter_staggered_grid_view package! Without it, this part wouldn't be available; please check out the library for more info on how it works!

所屬分類

依賴

依賴清單 7 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。