FLUTTER ECOSYSTEM

MarcelGarus/implicitly_animated_list

新しいアイテムで再構築されるたびに、リストを暗黙的にアニメーションするFlutterウィジェットです。

implicitly_animated_list のプロジェクト画像
Stars
11
Forks
8
最終プッシュ(UTC)
2024/12/21
プロジェクト状態
公開中
Marcel Garus GitHub avatar
GITHUB User

Marcel Garus ↗

I'm studying IT Systems Engineering and working on open source thingies. ✨ Especially excited about Flutter and Rust. 🌮 Feel free to contact me. he/him

Hasso Plattner InstitutePotsdam, Germany
言語DartSwiftKotlinObjective-C

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 3 件
  • flutter{"sdk":"flutter"}
  • list_diff^2.0.0
  • flutter_test開発用{"sdk":"flutter"}

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

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')),
    ),
    // ...
  ],
),