ListView as a BottomSheet

问题描述 投票:0回答:1

我想让我的底页有一个可滚动的项目列表,也可以通过向下拖动来将其消除。

这是我显示底页的方式:

_scaffoldKey.currentState.showBottomSheet(
  (context) {
    return ConstrainedBox(
      constraints: BoxConstraints(
        maxHeight: 200.0,
        minHeight: 0.0,
      ),
      child: Container(
        color: Colors.green,
        child: ListView(
          shrinkWrap: true,
          children: [....],
        ),
      ),
    );
  },
);

[我制作了一个可滚动底页的最小示例,这里是main.dart,您可以将其放入一个flutter项目中并运行它。

如何通过拖动该底片将其关闭?

这也是我想要实现的目标:gif

flutter flutter-layout
1个回答
0
投票

[您需要添加一个可用来检测您将整个底页向下拖动的区域,否则,将检测到垂直手势,就像您要在ListView上滚动一样。

任何类型的Widget都可以使用,在您的情况下,您可以在Container中使用顶部(或侧面)padding

© www.soinside.com 2019 - 2024. All rights reserved.