Mindinventory / flutter_draggable_gridview

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.
https://www.mindinventory.com/flutter-app-development.php
MIT License
100 stars 19 forks source link

Enhancement request: reduce abstract classes #8

Closed lukepighetti closed 2 years ago

lukepighetti commented 2 years ago

There are a lot of abstract classes where a callback would do. I have had to build three wrapping classes to get callback functionality.


class DragCompletionCallback extends DragCompletion {
  DragCompletionCallback(this.callback);

  final void Function(List<DraggableGridItem> list) callback;

  @override
  void onDragAccept(List<DraggableGridItem> list) {
    callback(list);
  }
}

class DragChildWhenDraggingCallback extends DragChildWhenDragging {
  DragChildWhenDraggingCallback(this.callback);

  final Widget Function(List<DraggableGridItem> list, int index) callback;

  @override
  Widget dragChildWhenDragging(List<DraggableGridItem> list, int index) {
    return callback(list, index);
  }
}

class DragPlaceHolderCallback extends DragPlaceHolder {
  DragPlaceHolderCallback(this.callback);

  final PlaceHolderWidget Function(List<DraggableGridItem> list, int index)
      callback;

  @override
  PlaceHolderWidget placeHolder(List<DraggableGridItem> list, int index) {
    return callback(list, index);
  }
}