搜索插件、代码仓与 APP 分类

插件详情v1.1.0

animated_stream_list

一个 Flutter 库,可轻松显示来自 Stream 的列表动画变化。它类似于带有动画的 StreamBuilder + ListView.Builder。

近 30 天下载
139
喜欢数
33
Pub 分数
30

安装插件

flutter pub add animated_stream_list

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可简化从 Stream 中显示带有动画更新的列表。它结合了 StreamBuilder 和 ListView.builder 的功能,并内置了插入、删除和更新的动画效果。非常适合实时数据库或用户输入等动态数据源,无需手动处理动画即可确保流畅的视觉过渡。该库轻量且易于集成到现有项目中。

适合场景

  • 实时数据流
  • 动态列表更新
  • 聊天应用消息列表
  • 用户生成内容显示
  • 实时仪表板数据

主要特点

  • 内置项目动画
  • 流驱动的列表更新
  • 最小化样板代码
  • 平滑的插入/删除过渡
  • 流变化时自动重建

适合对象

  • 寻求简单动画列表的开发者
  • 具有实时数据的项目
  • 需要响应式 UI 的应用
  • Flutter 初学者学习流
  • UI 密集型应用

使用建议

  • 超出基本动画之外的自定义功能有限
  • 不支持自定义滚动物理效果
  • 未针对超大数据集进行优化
  • 需要仔细管理流
  • 频繁更新可能影响性能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Animated Stream List

pub package Build Status

A Flutter library to easily display a list with animated changes from a Stream<List<E>>.
It's like StreamBuilder + ListView.Builder with animations.
Taken inspiration from the Animated List Sample and Java-diff-utils

Getting Started

1. Add dependency to your pubspec.yaml
dependencies:
  animated_stream_list: ^1.1.0
2. Import it
import 'package:animated_stream_list/animated_stream_list.dart';
3. Use it. See the examples folder for an ... example.

Parameters

@required Stream<List<E>> streamList;
@required AnimatedStreamListItemBuilder<E> itemBuilder; 
@required AnimatedStreamListItemBuilder<E> itemRemovedBuilder; 
Duration duration;

AnimatedStreamListItemBuilder<T> is just a function which builds a tile

typedef Widget AnimatedStreamListItemBuilder<T>(
  T item,
  int index,
  BuildContext context,
  Animation<double> animation,
); 

Example

// create tile view as the user is going to see it, attach any onClick callbacks etc. 
Widget _createTile(String item, Animation<double> animation) {    
 return SizeTransition(      
    axis: Axis.vertical,      
    sizeFactor: animation,      
    child: const Text(item),    
  ); 
}

// what is going to be shown as the tile is being removed, usually same as above but without any 
// onClick callbacks as, most likely, you don't want the user to interact with a removed view 
Widget _createRemovedTile(String item, Animation<double> animation) {    
 return SizeTransition(      
    axis: Axis.vertical,      
    sizeFactor: animation,      
    child: const Text(item),    
  ); 
}

final Stream<List<String>> list = // get list from some source, like BLOC  
final animatedView = AnimatedStreamList<String>(      
  streamList: list,      
  itemBuilder: (String item, int index, BuildContext context, Animation<double> animation) =>      
    _createTile(item, animation),      
  itemRemovedBuilder: (String item, int index, BuildContext context, Animation<double> animation) =>  
    _createRemovedTile(item, animation), 
  ); 
} 

Options

List<E> initialList;

Initial list

Equalizer equals; 

Compares items for equality, by default it uses the == operator, it's critical this works properly.

Equalizer is function, that, given two items of the same type, returns true if they are equal, false otherwise

typedef bool Equalizer(dynamic item1, dynamic item2); 

You can check the Animated List Documentation for the rest:

Axis scrollDirection;
bool reverse;
ScrollController scrollController;
bool primary;
ScrollPhysics scrollPhysics;
bool shrinkWrap;
EdgeInsetsGeometry padding;

Credits

This amazing package was originally created by Dawid Bota over here. I have taken over the development with his blessing and all tracking will be done on this repo moving forward.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。