搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。