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

插件详情v2.3.0

implicitly_animated_list

一个 Flutter 小部件,每当它使用新项目重建时,会隐式地动画化列表。

AndroidiOSmacOSWindowsLinux
近 30 天下载
2.3万
喜欢数
33
Pub 分数
150

安装插件

flutter pub add implicitly_animated_list

插件介绍

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

一个 Flutter 小部件,当列表使用新数据重建时,会自动为列表项添加动画效果,无需手动管理动画。它通过隐式动画流畅处理插入、删除和更新操作,非常适合聊天界面或任务看板等动态列表。该小部件可与标准 Flutter 列表无缝集成,设置简单。支持所有主要平台,设计简洁且性能出色。

适合场景

  • 动态列表更新
  • 带有消息到达的聊天 UI
  • 任务列表管理
  • 实时数据流
  • 动画项目过渡

主要特点

  • 自动插入动画
  • 平滑删除过渡
  • 内置更新处理
  • 最小化样板代码
  • 跨平台支持

适合对象

  • 寻求简单列表动画的开发者
  • 经常更新列表的应用程序
  • 需要视觉反馈以显示更改的UI
  • 初学者学习Flutter动画
  • 优先考虑开发人员效率的项目

使用建议

  • 对动画曲线的自定义有限
  • 不适合复杂的自定义动画
  • 在非常大的列表上可能会影响性能
  • 需要仔细管理状态以避免闪烁
  • 最适合中等大小的数据集

原始 README

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

Often, your lists represent some kind of data.

You can just pass the original list data to the ImplicitlyAnimatedList as well as an itemBuilder for building a widget from one data point, and it'll animate whenever the data changes:

ImplicitlyAnimatedList(
  // When you change items of this list and hot reload, the list animates.
  itemData: [1, 2, 3, 4],
  itemBuilder: (_, number) => ListTile(title: Text('$number')),
),

It works with all classes and works well with StreamBuilder:

class User {
  const User({required this.firstName, required this.lastName});

  final String firstName;
  final String lastName;

  // The ImplicitlyAnimatedList uses the == operator to compare items.
  bool operator ==(Object other) => other is User
    && firstName == other.firstName
    && lastName == other.lastName;
}

...

StreamBuilder<List<User>>(
  stream: someSource.usersStream,
  builder: (context, snapshot) {
    if (!snapshot.hasData) {
      return ...;
    }
    return ImplicitlyAnimatedList(
      itemData: snapshot.data,
      itemBuilder: (context, user) {
        return ListTile(title: Text('${user.firstName} ${user.lastName}'));
      }
    );
  }
)

Here's an example that generates random numbers and animates from one state to the next (notice it's only 10 fps because of being a GIF):

example showcase

In addition to ImplicitlyAnimatedList, there's also SliverImplicitlyAnimatedList for use in a CustomScrollView:

CustomScrollView(
  slivers: [
    SliverImplicitlyAnimatedList(
      itemData: myListOfItems,
      itemBuilder: (context, item) => ListTile(title: Text('$item')),
    ),
    // ...
  ],
),

所属分类

依赖

依赖清单 1 项

  • list_diff^2.0.0

源码仓库

使用此插件的项目