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

transformable_list_view のカバー
パッケージ詳細v0.8.0

transformable_list_view

スクロール位置に応じてアイテムの変形アニメーションを追加できるように拡張されたデフォルトのListViewを拡張するウィジェット

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
212
いいね数
133
Pub ポイント
150

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

flutter pub add transformable_list_view

パッケージ概要

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

ListView を拡張して、スクロール位置に基づいてリストアイテムのスムーズな変形アニメーションを可能にする Flutter ウィジェットです。アイテムがビューポートに入ったり出たりする際のスケーリング、回転、フェードなどの視覚効果を実装できるため、動的でインタラクティブなリストを作成できます。スクロールが多くなるインターフェースでのユーザー体験向上に最適です。このパッケージは Android、iOS、Web、macOS、Windows、Linux などすべての主要プラットフォームをサポートしています。

用途

  • アニメーションスクロールリストの作成
  • スクロールでトリガーされる変換によるUIの強化
  • 魅力的な製品カルーセルの構築
  • 没入型コンテンツフィードの設計
  • パララックス風のエフェクトを実装する
  • スクロール中に視覚フィードバックを追加する

主な機能

  • スクロール位置に基づくアイテム変換
  • スムーズなアニメーション遷移
  • クロスプラットフォーム互換性
  • 既存の ListView コードとの簡単な統合
  • スケール、回転、不透明度の変更に対応
  • カスタマイズ可能なアニメーションカーブとタイミング

適している対象

  • インタラクティブ要素を求めるUIデザイナー
  • スクロール駆動アニメーションを開発する開発者
  • 魅力的なリスト操作を必要とするアプリ
  • 複数のプラットフォームをターゲットにするプロジェクト
  • 洗練されたユーザー体験に注力するチーム

注意事項

  • 大規模なデータセットではパフォーマンスに影響する可能性があります
  • アニメーションパラメータの正確な調整が必要です
  • 中程度のリストサイズに最適
  • 非常に複雑なアニメーションには向かない
  • さまざまなデバイスおよびプラットフォームでのテストが必要です

元の README

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

Scrollable widgets with easily customizable transform animations.

Features

The package contains 3 widgets:

  • TransformableListView that extends ListView
  • TransformableSliverList that extends SliverList
  • TransformableSliver that extends SliverToBoxAdapter

Each of then has getTransformMatrix callback. In the callback you need to return Matrix4 that represetns transormation of the child at the current moment. If you don't need any transformations you can simply return Matrix4.identity().

In getTransformMatrix callback you receive TransformableListItem with the data about list item:

  • Offset offset is main axis offset of the child. By default (with vertical, non reversed scroll view) offset.dx is always 0 while offset.dy is the distance between top edge of the child and top edge of the viewport.
  • Size size is the child size received from its RenderBox.
  • SliverConstraints constraints describes the current scroll state of the viewport from the point of view of the sliver receiving the constraints.
  • int? index is the index of the child. Will be null when using TransformableSliver.
  • TransformableListItemPosition position is child position on the main axis viewport. Can be .topEdge, .middle or .bottomEdge.
  • double visibleExtent is currently visible portion of item. For example, if item is hidden it will be 0 while it's completely displayed will equal to size.height or size.width depending on axis.

Usage

First you need to add TransformableListView where you need transformations

TransformableListView.builder(
  getTransformMatrix: getTransformMatrix,
  itemBuilder: (context, index) {
    return Container(
      height: 100,
      margin: const EdgeInsets.symmetric(
        horizontal: 16,
        vertical: 4,
      ),
      decoration: BoxDecoration(
        color: index.isEven ? Colors.grey : Colors.blueAccent,
        borderRadius: BorderRadius.circular(20),
      ),
      alignment: Alignment.center,
      child: Text(index.toString()),
    );
  },
  itemCount: 30,
),

Second you need to implement getTransformMatrix callback

Matrix4 getTransformMatrix(TransformableListItem item) {
  /// final scale of child when the animation is completed
  const endScaleBound = 0.3;

  /// 0 when animation completed and [scale] == [endScaleBound]
  /// 1 when animation starts and [scale] == 1
  final animationProgress = item.visibleExtent / item.size.height;

  /// result matrix
  final paintTransform = Matrix4.identity();

  /// animate only if item is on edge
  if (item.position != TransformableListItemPosition.middle) {
    final scale = endScaleBound + ((1 - endScaleBound) * animationProgress);

    paintTransform
      ..translate(item.size.width / 2)
      ..scale(scale)
      ..translate(-item.size.width / 2);
  }

  return paintTransform;
}

You can implement your own callback or check more at /example folder.

Additional information

You can read more about matrix transfomations in Flutter here. Any feedback and PRs are welcome.

Developed by TBR Group.

カテゴリー

ソースリポジトリ

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

データはまだありません。