Android简单实用的可拖拽GridView组件分享

  DraggableGridViewBuilder(

  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

  crossAxisCount: 2,

  childAspectRatio: MediaQuery.of(context).size.width /

  (MediaQuery.of(context).size.height / 3),

  ),

  children: _makeGridItems(12),

  isOnlyLongPress: true,

  dragCompletion:

  (List list, int beforeIndex, int afterIndex) {

  if (kDebugMode) {

  print('onDragAccept: $beforeIndex -> $afterIndex');

  }

  },

  dragFeedback: (List list, int index) {

  return SizedBox(

  width: 200,

  height: 150,

  child: list[index].child,

  );

  },

  dragStartBehavior: DragStartBehavior.start,

  dragPlaceHolder: (List list, int index) {

  return PlaceHolderWidget(

  child: Container(

  color: Colors.blue[100],

  ),

  );

  },

  )