v1.0.0flutter_draggable_gridview
此套件可幫助您為現有的 GridView.builder 新增拖曳與放置功能。
此套件支援在 GridView.builder 內進行多平台的拖曳與放置元件。它提供 GridView.builder 中所有可用的屬性,並可輕鬆以少數程式碼實作。
{"sdk":"flutter"}{"sdk":"flutter"}^3.0.1以下為英文專案原文快照,最新內容請造訪 GitHub。
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
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,
),
);
},
);
A delegate that controls the layout of the children within the GridView.
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.
This callback provides updated list and old and new indexes.
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'.
With this callback, you have to return a Widget and we will use this widget in feedback. Learn more about feedback from Draggable class.
TWith this callback, you have to return a PlaceHolderWidget and we will use this widget in place holder.
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.
GridView.builder properties with DraggableGridViewBuilder class.The result returns in List. so it can be lost later, you are responsible for storing it somewhere permanent (if needed).
Contribution towards our repository is always welcome, we request contributors to create a pull request to the develop branch only.
It would be great for us if the reporter can share the below things to understand the root cause of the issue.
Flutter Draggable GridView is MIT-licensed.
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.