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

reorderable_grid_view のカバー
パッケージ詳細v2.2.8

reorderable_grid_view

再配置可能なグリッドビュー

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
5.4万
いいね数
164
Pub ポイント
120

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

flutter pub add reorderable_grid_view

パッケージ概要

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

グリッドレイアウト内のアイテムのドラッグアンドドロップによる並べ替えを可能にするFlutterパッケージです。GridViewの機能を拡張し、ユーザーがジェスチャーを使ってタイルを直感的に再配置できるようにします。カスタマイズ可能なダッシュボード、タスクボード、または動的なアイテム配置が必要な任意のUIに最適です。モバイル、ウェブ、デスクトップを含むすべての主要プラットフォームをサポートしており、デバイス間で一貫した動作を保証します。パフォーマンスと統合のしやすさを重視して設計されており、既存のFlutterアプリケーションとのシームレスな連携が可能です。

用途

  • カスタマイズ可能なダッシュボードレイアウト
  • タスク管理インターフェース
  • 写真ギャラリーの再配置
  • ユーザーの好みに基づくアイテム順序付け
  • インタラクティブなグリッドベースの設定

主な機能

  • ドラッグアンドドロップによる再順序付け
  • クロスプラットフォーム互換性
  • 既存の GridView との簡単な統合
  • カスタムドラッグハンドルをサポート
  • スムーズな遷移のための組み込みアニメーション

適している対象

  • インタラクティブなグリッドUIを構築する開発者
  • ユーザー主導のコンテンツ配置を必要とするアプリ
  • 動的なレイアウト要件を持つプロジェクト

注意事項

  • 状態管理の適切な取り扱いが必要です
  • 非常に大きなデータセットではパフォーマンスに影響を与える可能性があります
  • ドラッグフィードバックのカスタマイズが限定的
  • 非常に高い頻度の更新には最適化されていません

元の README

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

ReorderableGridView

Idea from official ReorderableListView

Usage:

dependencies:
  reorderable_grid_view: ^2.2.9-alpha.4

Example

Sceenshot
class _MyHomePageState extends State<MyHomePage> {
  final data = [1, 2, 3, 4, 5];

  @override
  Widget build(BuildContext context) {
    Widget buildItem(String text) {
      return Card(
        key: ValueKey(text),
        child: Text(text),
      );
    }

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),

      body: Center(
        // use ReorderableGridView.count() when version >= 2.0.0
        // else use ReorderableGridView()
        child: ReorderableGridView.count(
          crossAxisSpacing: 10,
          mainAxisSpacing: 10,
          crossAxisCount: 3,
          children: this.data.map((e) => buildItem("$e")).toList(),
          onReorder: (oldIndex, newIndex) {
            setState(() {
              final element = data.removeAt(oldIndex);
              data.insert(newIndex, element);
            });
          },
          footer: [
            Card(
              child: Center(
                child: Icon(Icons.add),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Options

option desc
dragWidgetBuilderV2 the drag widget builder
restrictDragScope restrict drag scope to ReorderableGridView, not drag over the scree, default is false
dragStartDelay the longPress time
scrollDirection the scroll direction, default is Axis.vertical, supports Axis.horizontal
scrollSpeedController control how speed when scroll down when drag out of viewport
OnDropIndexChange the drop position changed, void (index, oldIndex), oldIndex = nil if is drag start.

dragWidgetBuilderV2

Normaly you can do like this:

dragWidgetBuilderV2: DragWidgetBuilderV2(
	isScreenshotDragWidget: false,
	builder: (index, child, screenshot) {
		return child;
	}
)
  • child is you dragging widget.

And if you dragging widget has some state, the callback's child can't access the state. So you can do a screenshot like this.

dragWidgetBuilderV2: DragWidgetBuilderV2(
	isScreenshotDragWidget: true,
	builder: (index, child, screenshot) {
		return Image(screenshot);
	}
)

Constructors

  • ReorderableGridView.builder
  • ReorderableGridView.count
  • ReorderableSliverGridView.count

custom reorderable

You can use ReorderableWrapperWidget to custom your reorderable. Use ReorderableWrapperWidget as root. and it's descendants is ReorderableItemView[] list

  • ReorderableWrapperWidget(child: SomeCollection(children: ReorderableItemView))

Important

  • the placeholderBuilder is not right when the list is very long, is not fixable for now. please see issue 47
  • can drag out of scope in ReorderableSliverGridView, please see issue 52

TODO

fix placeholderBuilder is not right when the list is very long

Other link project

If this project is not fit your meet, you can try those other projects

カテゴリー

ソースリポジトリ

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