美文网首页
Flutter 可拖拽的 Gridview

Flutter 可拖拽的 Gridview

作者: Beoyan | 来源:发表于2023-03-16 09:39 被阅读0次

    Flutter 可拖拽的 Gridview

    githublogo.jpg

    ### Draggable GridView.

    2023-03-17 09.48.01.gif

    flutter_draggable_gridview的基础上添加了同时多个GridView的适配 同时添加了 SliverDraggableGridViewBuilder 用于CustomScrollView

    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,
                ),
              );
            },
          );
    

    相关文章

      网友评论

          本文标题:Flutter 可拖拽的 Gridview

          本文链接:https://www.haomeiwen.com/subject/csgrrdtx.html