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

flutter_draggable_gridview 封面
插件详情v1.0.0

flutter_draggable_gridview

该包可帮助您为现有的 GridView.builder 添加拖放功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
5490
喜欢数
136
Pub 分数
155

安装插件

flutter pub add flutter_draggable_gridview

插件介绍

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

一个 Flutter 包,为 GridView.builder 提供拖放功能,允许用户重新排序网格布局中的项目。它可无缝集成到现有的网格结构中,无需进行大量代码更改。专为跨多个平台的流畅、响应式交互设计,可增强需要自定义或交互式网格布局的应用程序的用户体验。该包轻量且易于实现,非常适合任务管理器、仪表板或图像画廊中的列表重新排序。

适合场景

  • 重新排序任务列表中的项目
  • 可自定义的仪表板布局
  • 图像画廊项目重新排列
  • 交互式产品网格
  • 基于用户偏好的排序
  • 可拖动的内容管理

主要特点

  • 与 GridView.builder 的无缝集成
  • 跨平台支持(Android、iOS、Web、macOS、Windows、Linux)
  • 流畅的拖拽动画
  • 所需设置最少
  • 支持自定义拖动手柄
  • 在重新排序时保持网格结构

适合对象

  • 开发交互式网格界面的开发者
  • 需要用户驱动项重新排序的应用程序
  • 具有动态内容布局的项目
  • 以用户体验为中心的应用程序
  • 注重跨平台一致性的团队

使用建议

  • 可能需要额外的状态管理
  • 大数据集的性能影响
  • 对复杂拖动行为的自定义有限
  • 不适用于非网格滚动控件
  • 需要仔细处理项目键
  • 最适合用于小型到中型数据集

原始 README

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

flutter_draggable_gridview

flutter_draggable_gridview version flutter_draggable_gridview Git Stars MIT License

This package supports drag & drop widgets inside the GridView.builder for multiplatform. It provides all the properties which are available in Gridview.builder and easy to implement with the few lines of code.

Draggable GridView.

Draggable GridView

Usage

Example
      DraggableGridViewBuilder(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 2,
          childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 3),
        ),
        children: _listOfDraggableGridItem,
        isOnlyLongPress: false,
        dragCompletion: (List<DraggableGridItem> list, int beforeIndex, int afterIndex) {
          print( 'onDragAccept: $beforeIndex -> $afterIndex');
        },
        dragFeedback: (List<DraggableGridItem> list, int index) {
          return Container(
            child: list[index].child,
            width: 200,
            height: 150,
          );
        },
        dragPlaceHolder: (List<DraggableGridItem> list, int index) {
          return PlaceHolderWidget(
            child: Container(
              color: Colors.white,
            ),
          );
        },
      );
Required parameters
gridDelegate:

A delegate that controls the layout of the children within the GridView.

children:

This property contains list of [DraggableGridItem] and it is use to show the widget inside the GridView.builder to provide the drag & drop functionality. Also, it contains isDraggable parameter which manages enable/disable the drag & drop functionality.

dragCompletion:

This callback provides updated list and old and new indexes.

Optional parameters
isOnlyLongPress:

This property contains bool value. If this property is false then it works with simple press draggable or else it works with long press. default value is 'true'.

dragFeedback:

With this callback, you have to return a Widget and we will use this widget in feedback. Learn more about feedback from Draggable class.

dragPlaceHolder:

TWith this callback, you have to return a PlaceHolderWidget and we will use this widget in place holder.

dragChildWhenDragging:

With this callback, you have to return a Widget and we will display this widget instead of child when drags are under way. Learn more about childWhenDragging from Draggable class.

Last But Not Least :heart_eyes:
You can use all the GridView.builder properties with DraggableGridViewBuilder class.

Note:

The result returns in List. so it can be lost later, you are responsible for storing it somewhere permanent (if needed).

Guideline for contributors

Contribution towards our repository is always welcome, we request contributors to create a pull request to the develop branch only.

Guideline to report an issue/feature request

It would be great for us if the reporter can share the below things to understand the root cause of the issue.

  • Library version
  • Code snippet
  • Logs if applicable
  • Device specification like (Manufacturer, OS version, etc)
  • Screenshot/video with steps to reproduce the issue

LICENSE!

Flutter Draggable GridView is MIT-licensed.

Let us know!

We’d be really happy if you send us links to your projects where you use our component. Just send an email to sales@mindinventory.com And do let us know if you have any questions or suggestion regarding our work.

所属分类

源码仓库

使用此插件的项目