搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。