パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.5.1

diffutil_sliverlist

diffutil.dart を使って変更を暗黙的にアニメーションする SliverList。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
3280
いいね数
61
Pub ポイント
140

パッケージをインストール

flutter pub add diffutil_sliverlist

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

DiffUtilアルゴリズムを使用してアイテムの変更を自動的にアニメーション化するSliverListウィジェットであり、基になるデータリストが変更されたときにスムーズかつ効率的な更新を保証します。diffutil.dartを使用して、古いリストと新しいリスト間の最小差分を計算し、必要なアニメーションと再構築のみを適用します。パフォーマンスと視覚的な滑らかさが重要な大規模で動的なスクロール可能なリストに最適です。このパッケージはFlutterのSliverアーキテクチャとシームレスに統合され、すべての主要プラットフォームをサポートしています。

用途

  • 頻繁な更新を持つ動的スクロールリスト
  • スクロール可能なビュー内のアイテムの効率的な並べ替え
  • リストアイテムの追加/削除時のスムーズな遷移
  • 最適化されたレンダリングを必要とする大規模なデータセット
  • スクロール可能なインターフェースにおけるリアルタイムデータフィード

主な機能

  • リストの変更の自動アニメーション
  • 最小更新のために DiffUtil を使用します
  • 大規模なリスト向けのパフォーマンス最適化
  • Sliver ウィジェットとのシームレスな統合
  • すべてのFlutterターゲットにおけるクロスプラットフォーム対応

適している対象

  • スムーズなリストアニメーションが必要な開発者
  • リアルタイムまたは頻繁に変化するデータを備えたアプリ
  • パフォーマンスに敏感なスクロールインターフェース
  • Sliverベースのレイアウトを使用するFlutter開発者
  • リストの差分を比較するために最小限のボイラープレートが必要なプロジェクト

注意事項

  • DiffUtilの概念を理解する必要があります
  • 非常に小さなリストの場合、オーバーヘッドが発生する可能性があります
  • アニメーション動作のカスタマイズが限定的
  • 外部の diffutil.dart パッケージに依存しています
  • リスト以外のスリバー型には適していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

diffutil_sliverlist

Pub Package Build Status codecov

A SliverList that implicitly animates changes.

It supports two use cases:

Animating changes from a list of widgets with unique keys

When you have a list of Widgets and can give each Widget a unique key, you can use DiffUtilSliverList.fromKeyedWidgetList.

See the example code:

class _ExpandableListsState extends State<ExpandableLists> {
  bool expanded = false;

  @override
  Widget build(BuildContext context) {
    return DiffUtilSliverList.fromKeyedWidgetList(
      children: [
        ListTile(
          key: Key("1"),
          title: Text("first"),
          trailing: Icon(Icons.chevron_right),
        ),
        ListTile(
          key: Key("2"),
          title: Text("second"),
          trailing: Icon(Icons.chevron_right),
        ),
        if (this.expanded)
          for (int i = 3; i < 6; i++)
            ListTile(
              key: Key(i.toString()),
              title: Text("index: $i"),
              trailing: Icon(Icons.chevron_right),
            ),
        ListTile(
          key: Key("expand_collapse"),
          onTap: () => setState(() {
            expaned = !expaned;
          }),
          title: Text(expanded ? "collapse" : "expand", style: TextStyle(fontWeight: FontWeight.bold),),
          trailing: Icon(expanded ? Icons.expand_less : Icons.expand_more),
        )
      ],
      insertAnimationBuilder: (context, animation, child) => FadeTransition(
        opacity: animation,
        child: child,
      ),
      removeAnimationBuilder: (context, animation, child) => FadeTransition(
        opacity: animation,
        child: SizeTransition(
          sizeFactor: animation,
          axisAlignment: 0,
          child: child,
        ),
      ),
    );
  }
}

And the result:

Building Widgets from a list of data objects that implement ==

Example:


Widget build(BuildContext context) {
    return CustomScrollView(
             slivers: [
               DiffUtilSliverList<int>(
                 items: list,
                 builder: (context, item) => 
                   Container(
                     color: colors[item % colors.length],
                     height: 48,
                     width: double.infinity,
                 ),
                 insertAnimationBuilder: (context, animation, child) =>
                     FadeTransition(
                       opacity: animation,
                       child: child,
                 ),
                 removeAnimationBuilder: (context, animation, child) =>
                     SizeTransition(
                       sizeFactor: animation,
                       child: child,
                 ),
                 removeAnimationDuration: const Duration(milliseconds: 3000),
                 insertAnimationDuration: const Duration(milliseconds: 1200),
             ),
           ],
         );
}

If list changes, the list will automatically animate new/removed items:

If the items don't implement == correctly, you can pass your own equalityChecker.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト