1

我有一个建设者的DraggableScrollableSheet内心。showModalBottomSheet我已经设置isDismissible: true了模态表,但我的小部件只能在边缘拖动。那是因为我有一个ListView内部DraggableScrollableSheet

当列表在拖动开始时过度滚动时我应该怎么做?

这是我的代码:

 showModalBottomSheet<void>(
      context: context,
      isScrollControlled: true,
      isDismissible: true,
      backgroundColor: Colors.transparent,
      enableDrag: true,
      builder: (BuildContext context) {
        return StackedSheet(
          backgroundColor: backgroundColor,
          onBackgroundColor: onBackgroundColor,
          padding: padding,
          minChildSize: minChildSize,
          maxChildSize: maxChildSize,
          onClose: onClose,
          child: SafeArea(
            top: false,
            child: child,
          ),
        );
      },
    );

StackedSheet在哪里:

LayoutBuilder(
        builder: (context, constraints) {
          return DraggableScrollableSheet(
            key: Key('$_childSize'),
            initialChildSize: min(_childSize, widget.maxChildSize),
            minChildSize:
                min(_childSize - _childSize * 0.2, widget.minChildSize),
            maxChildSize: min(_childSize, widget.maxChildSize),
            expand: false,
            builder: (
              BuildContext context,
              ScrollController scrollController,
            ) {
              return ListView.separated( ...blah blah)
           }

这是一个GIF:

这是一个GIF:

我的愿望不是弹跳,而是开始被拖累。

4

1 回答 1

1

在我看来,您可以使用滚动控制器在达到类似这样的顶部时关闭底页

if (_controller.offset <= _controller.position.minScrollExtent &&
            !_controller.position.outOfRange) {
           .....
           ..... 
         );
       }

shrinkWrap=true您可以使用Listview阻止列表在顶部弹跳。要关闭底部表,您可以参考此 stackoverflow 帖子

我没有尝试过这段代码,但希望它能以某种方式帮助你。

另外,我认为如果您通过在“X”右侧的顶部插入一个小“-”来保持它现在的样子,它会看起来很好,用户可以触摸它以向下滑动。

于 2021-07-06T11:42:45.643 回答