搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案